Skip to content

Commit 6ae5053

Browse files
committed
overrides are array not an object. Even tho it works it's better to have it as an array
Readme updates
1 parent a3d7400 commit 6ae5053

File tree

4 files changed

+1476
-58
lines changed

4 files changed

+1476
-58
lines changed

README.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
Plain config without any rules that makes ESLint working with typescript
44

55
## How to use.
6+
67
- Install it as a dependency.
8+
79
```
810
yarn add eslint-config-plain-typescript
911
```
10-
- Make sure you have `typescript` and `tsconfig.json` in root of the project
12+
13+
- Make sure you have `typescript` and `tsconfig.json` in root of the project
1114

1215
- Add in your `.eslintrc` extension like that:
16+
1317
```
1418
"extends": ["plain-typescript"]
1519
```
@@ -20,30 +24,45 @@ Plain config without any rules that makes ESLint working with typescript
2024

2125
There is some rules that are not compatible with `js` so when you use them it's nice
2226
to put the inside of the `override` object in your `.eslintrc` config like that.
27+
2328
```json5
2429
{
25-
"extends": ["airbnb", "plain-typescript"],
26-
"overrides": {
27-
files: ["**/*.ts", "**/*.tsx"],
28-
"rules": { // These are rules that should apply to ts/tsx files only
29-
"@typescript-eslint/no-unused-vars": "error"
30+
extends: ["airbnb", "plain-typescript"],
31+
overrides: [
32+
{
33+
files: ["**/*.ts", "**/*.tsx"],
34+
rules: {
35+
// These are rules that should apply to ts/tsx files only
36+
"@typescript-eslint/no-unused-vars": "error"
37+
}
3038
}
31-
},
32-
"rules": { // These are rules that go for both and are proven to not be conflicting
39+
],
40+
rules: {
41+
// These are rules that go for both and are proven to not be conflicting
3342
"no-unused-vars": "error"
3443
}
3544
}
3645
```
3746

3847
Also please refer to the `typescript` [recommended config](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json) for more info about available rules and rules that are incompatible.
3948

49+
## Compatibility with other plugins
50+
51+
Few rules are incompatible and need special plugins/configs.
52+
For example `plugin:import/typescript` is needed to be extended so `eslint-plugin-import` will start working properly
53+
if you will extend `airbnb` preset for example etc.
54+
It's described [here](https://github.com/benmosher/eslint-plugin-import#typescript) in detail.
55+
4056
## Note
4157

4258
Not 100% sure, but put it after all the other configs that you may import.
43-
The only configs that you should export after is `prettier` related stuff, others should go before this one I assume.
59+
The only configs that you should extend after is `prettier` related stuff, others should go before this one I assume.
60+
More on `prettier` integraion [here](https://github.com/prettier/eslint-config-prettier#installation)
4461

4562
## Depends on.
63+
4664
There three suckers gonna be installed along the way with installation.
65+
4766
```
4867
"dependencies": {
4968
"babel-eslint": "10.0.1",
@@ -53,6 +72,7 @@ There three suckers gonna be installed along the way with installation.
5372
```
5473

5574
These two suckers should be installed separatly as `devDependencies`:
75+
5676
```
5777
"peerDependencies": {
5878
"eslint": ">=5.15",

index.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,31 @@ module.exports = {
2525
jsx: true
2626
}
2727
},
28-
overrides: {
29-
files: ["**/*.ts", "**/*.tsx"],
30-
parser: "@typescript-eslint/parser",
31-
parserOptions: {
32-
ecmaVersion: 2018,
33-
sourceType: "module",
34-
ecmaFeatures: {
35-
jsx: true
36-
},
28+
overrides: [
29+
{
30+
files: ["**/*.ts", "**/*.tsx"],
31+
parser: "@typescript-eslint/parser",
32+
parserOptions: {
33+
ecmaVersion: 2018,
34+
sourceType: "module",
35+
ecmaFeatures: {
36+
jsx: true
37+
},
3738

38-
// typescript-eslint specific options
39-
project: tsConfigPath,
40-
tsconfigRootDir: projectRootPath,
41-
warnOnUnsupportedTypeScriptVersion: true
42-
},
43-
plugins: ["@typescript-eslint"],
44-
rules: {
45-
// These ESLint rules are known to cause issues with typescript-eslint
46-
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json
47-
camelcase: "off",
48-
indent: "off",
49-
"no-array-constructor": "off",
50-
"no-unused-vars": "off"
39+
// typescript-eslint specific options
40+
project: tsConfigPath,
41+
tsconfigRootDir: projectRootPath,
42+
warnOnUnsupportedTypeScriptVersion: true
43+
},
44+
plugins: ["@typescript-eslint"],
45+
rules: {
46+
// These ESLint rules are known to cause issues with typescript-eslint
47+
// See https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/recommended.json
48+
camelcase: "off",
49+
indent: "off",
50+
"no-array-constructor": "off",
51+
"no-unused-vars": "off"
52+
}
5153
}
52-
}
54+
]
5355
};

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
],
1313
"devDependencies": {
1414
"eslint": "^5.15.3",
15-
"typescript": "^3.3.3333"
15+
"typescript": "^3.3.3333",
16+
"np": "^4.0.2"
1617
},
1718
"dependencies": {
1819
"babel-eslint": "10.0.1",
@@ -24,6 +25,8 @@
2425
"typescript": "^>=3"
2526
},
2627
"scripts": {
27-
"test": "eslint checkme.ts && exit 1 || exit 0"
28+
"test": "eslint checkme.ts && exit 1 || exit 0",
29+
"prepublish": "yarn test",
30+
"release": "np"
2831
}
2932
}

0 commit comments

Comments
 (0)