Skip to content

Commit

Permalink
Update README.md with working Typescript setup (#1434)
Browse files Browse the repository at this point in the history
Update README.md with working Typescript setup
  • Loading branch information
feross committed Oct 6, 2019
2 parents f4d3113 + d901c54 commit cfb84fa
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,21 +547,32 @@ To use TypeScript, you need to run `standard` with `@typescript-eslint/parser` a
`@typescript-eslint/eslint-plugin` as a plugin, and tell standard to lint `**/*.ts` files (since it
doesn't by default).

Unfortunately, there's an outstanding [issue](https://github.com/standard/standard/issues/1283)
with `standard` and Typescript where `standard` would incorrectly emit unused-variable errors
(e.g: when you import interfaces). And as a workaround, you need to use
[standardx](https://github.com/standard/standardx) instead:sweat_smile:.

```bash
npm install @typescript-eslint/parser @typescript-eslint/eslint-plugin --save-dev
npm install standardx @typescript-eslint/parser @typescript-eslint/eslint-plugin --save-dev
```

Then run:

```bash
$ standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin **/*.ts
$ standardx --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin **/*.ts
```

Or, add this to `package.json`:

```json
{
"standard": {
"eslintConfig": {
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error"
}
},
"standardx": {
"parser": "@typescript-eslint/parser",
"plugins": [ "@typescript-eslint/eslint-plugin" ]
}
Expand All @@ -571,7 +582,14 @@ Or, add this to `package.json`:
With that in `package.json`, you can run:

```bash
standard **/*.ts
standardx **/*.ts
```

And you probably should remove `standard` too to avoid confusion where it's used by mistake
instead of `standardx`.

```bash
npm uninstall standard
```

## What about Mocha, Jest, Jasmine, QUnit, etc?
Expand Down

0 comments on commit cfb84fa

Please sign in to comment.