1.0.44 • Published 3 years ago

inclusivelint-lib v1.0.44

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

inclusivelint-lib

This repository holds all the code for the inclusivelint TypeScript library, which is located here.

Inclusivelint is a project that helps engineers to write code that is inclusive, making sure to tag all the words that are not inclusive and showing suggestions for it. For example, after scanning the files with this lib, you can see a output like this one:

{ lineNumber: 1,
  term: 'master',
  termStartIndex: 9,
  termEndIndex: 14,
  termLineStartIndex: 10,
  termLineEndIndex: 16,
  suggestedTerms:
   'primary, primaries, hub, hubs, reference, references, replica, replicas, spoke, spokes, secondary, secondaries'
}

This json shows that the word master was found in the index 9 and it ends on index 14. And it also shows some possible substitutions.

How to use

Using the library is really straight forward and can be done like this:

import { InclusiveDiagnostic, scanFile } from "@inclusivelint/inclusivelint";


async function main() {
    //use scanfile if reading from a file
    var allDiagnostics: InclusiveDiagnostic[] = await scanFile('path_to_file');

    for (let diagnostic of allDiagnostics) {
        console.log(diagnostic);
    }

    var fileContent: string = readFileSync(filePath, 'utf8');

    //use the scan method with the string content of the file
    var allDiagnosticsFromContent: InclusiveDiagnostic[] = await scan(fileContent);

    for (let diagnostic of allDiagnosticsFromContent) {
        console.log(diagnostic);
    }
}

main();

So, basically there are two methods you can use to have inclusive diagnostics:

    async function scanFile(filePath: string): Promise<InclusiveDiagnostic[]>

Async method that receives a path to the file you want to have a diagnostic and return a list of InclusiveDiagnostic.

    async function scan(fileContent: string): Promise<InclusiveDiagnostic[]>

Async method that receives the string content you want to have a diagnostic and return a list of InclusiveDiagnostic.

The object that is being returned as a component of a list has the following properties:

interface InclusiveDiagnostic {
    /**
     * Line number in which the diagnostic is pointing to.
     */
    lineNumber: number;
    /**
     * Term found by the linter.
     */
    term: string;
    /**
     * Occurrence start index related to the whole file - line breaks are considered as common characters.
     */
    termStartIndex: number;
    /**
     * Occurrence end index related to the whole file - line breaks are considered as common characters.
     */
    termEndIndex: number;
    /**
     * Occurrence start index of the corresponding line.
     */
    termLineStartIndex: number;
    /**
     * Occurrence end index of the corresponding line.
     */
    termLineEndIndex: number;
    /**
     * Suggested terms to be used.
     */
    suggestedTerms: string;
}
1.0.44

3 years ago

1.0.43

3 years ago

1.0.42

3 years ago

1.0.41

3 years ago

1.0.39

3 years ago

1.0.38

3 years ago

1.0.40

3 years ago

1.0.37

3 years ago

1.0.36

3 years ago

1.0.35

3 years ago

1.0.34

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.31

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.26

3 years ago

1.0.27

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.2

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago