# inclusivelint

> Core library for inclusivelint

Latest version **0.0.17** (published 2020-12-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install inclusivelint
pnpm add inclusivelint
yarn add inclusivelint
bun add inclusivelint
```

Provides the command `inclusivelint`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.17 |
| Published | 2020-12-29 |
| First published | 2020-12-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 9 |
| Author | inclusivelint |
| Maintainers | guilucas |

## Links

- npm: https://www.npmjs.com/package/inclusivelint
- Repository: https://github.com/inclusivelint/inclusivelint-lib
- Homepage: https://github.com/inclusivelint/inclusivelint-lib#readme
- Issues: https://github.com/inclusivelint/inclusivelint-lib/issues
- npm.io page: https://npm.io/package/inclusivelint

## Dependencies (11)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [ora](https://npm.io/package/ora.md) ^5.1.0
- [glob](https://npm.io/package/glob.md) ^7.1.6
- [http](https://npm.io/package/http.md) ^0.0.1-security
- [path](https://npm.io/package/path.md) ^0.12.7
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [clear](https://npm.io/package/clear.md) ^0.1.0
- [figlet](https://npm.io/package/figlet.md) ^1.5.0
- [nodejs](https://npm.io/package/nodejs.md) ^0.0.0
- [commander](https://npm.io/package/commander.md) ^6.2.0
- [typed-rest-client](https://npm.io/package/typed-rest-client.md) ^1.7.3

## Recent versions

- 0.0.17 (latest) — 2020-12-29
- 0.0.16 — 2020-12-28
- 0.0.15 — 2020-12-22
- 0.0.14 — 2020-12-22
- 0.0.13 — 2020-12-21
- 0.0.12 — 2020-12-21

## README

# inclusivelint

This repository holds all the code for the inclusivelint TypeScript library, which is located [here](https://www.npmjs.com/package/inclusivelint).

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:

``` json
{ 
    "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 as a TypeScript Library

After running the installation command:

``` sh
npm install inclusivelint
```

Using the library is really straight forward and can be done like this:

``` typescript
import { InclusiveDiagnostic, scanFile } from "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:

``` typescript
    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.

``` typescript
    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:

``` typescript
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;
}
```

### Using as a command line tool

Once you run the command to install the library, you will also be able to use the command line.
Use the same command to install the library:

``` sh
npm install inclusivelint
```

There are two parameters you can use to run the command line:

``` txt
-p, --path <path>  Path to be scaned. If its a folder, use the -r ou --resursive option
-r, --recursive    If the --path option is a folder, use this option to run recursively. Not needed if its path is a file
```

In other words, to run the command recursively, do this:

``` sh
inclusivelint -r -p path_to_be_scanned
```

To run in a single file, do:

``` sh
inclusivelint -p path_to_the_file_to_be_scanned
```

---
_Source: https://npm.io/package/inclusivelint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
