Skip to content

Commit 1161b41

Browse files
committed
Switch to @typescript-eslint/eslint-plugin
See https://eslint.org/blog/2019/01/future-typescript-eslint
1 parent fdda6f1 commit 1161b41

File tree

4 files changed

+119
-36
lines changed

4 files changed

+119
-36
lines changed

index.js

Lines changed: 107 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict';
22
module.exports = {
3-
parser: 'typescript-eslint-parser',
3+
parser: '@typescript-eslint/parser',
44
plugins: [
5-
'typescript'
5+
'@typescript-eslint'
66
],
77
settings: {
88
'import/resolver': {
@@ -16,39 +16,124 @@ module.exports = {
1616
}
1717
},
1818
'import/parsers': {
19-
'typescript-eslint-parser': [
19+
'@typescript-eslint/parser': [
2020
'.ts',
2121
'.tsx'
2222
]
2323
}
2424
},
2525
rules: {
26-
'typescript/adjacent-overload-signatures': 'error',
27-
'typescript/class-name-casing': 'error',
28-
'typescript/explicit-function-return-type': [
26+
'@typescript-eslint/adjacent-overload-signatures': 'error',
27+
'@typescript-eslint/array-type': [
28+
'error',
29+
'array'
30+
],
31+
'@typescript-eslint/ban-types': [
32+
'error',
33+
{
34+
types: {
35+
String: {
36+
message: 'Use `string` instead.',
37+
fixWith: 'string'
38+
},
39+
Number: {
40+
message: 'Use `number` instead.',
41+
fixWith: 'number'
42+
},
43+
Boolean: {
44+
message: 'Use `boolean` instead.',
45+
fixWith: 'boolean'
46+
},
47+
Object: {
48+
message: 'Use `object` instead.',
49+
fixWith: 'object'
50+
},
51+
object: 'Use `{}` instead.',
52+
Function: 'Use a specific function type instead, like `() => void`.',
53+
any: {
54+
message: 'Use `unknown` instead.',
55+
fixWith: 'unknown'
56+
},
57+
// TODO: Enforce `undefined` over `null` here too?
58+
}
59+
}
60+
],
61+
'camelcase': 'off',
62+
'@typescript-eslint/camelcase': [
63+
'error',
64+
{
65+
properties: 'always',
66+
ignoreDestructuring: false,
67+
}
68+
],
69+
'@typescript-eslint/class-name-casing': 'error',
70+
'@typescript-eslint/explicit-function-return-type': [
2971
'error',
3072
{
3173
allowExpressions: true
3274
}
3375
],
34-
'typescript/generic-type-naming': [
76+
'@typescript-eslint/generic-type-naming': [
3577
'error',
3678
'^[A-Z][a-zA-Z]+$'
3779
],
38-
'typescript/member-delimiter-style': 'error',
39-
'typescript/member-ordering': 'error',
40-
'typescript/no-angle-bracket-type-assertion': 'error',
41-
'typescript/no-array-constructor': 'error',
42-
'typescript/no-empty-interface': 'error',
43-
'typescript/no-inferrable-types': 'error',
44-
'typescript/no-namespace': 'error',
45-
'typescript/no-non-null-assertion': 'error',
46-
'typescript/no-triple-slash-reference': 'error',
47-
'typescript/no-type-alias': 'error',
48-
'typescript/no-unused-vars': 'error',
49-
'typescript/no-use-before-define': 'error',
50-
'typescript/no-var-requires': 'error',
51-
'typescript/prefer-namespace-keyword': 'error',
52-
'typescript/type-annotation-spacing': 'error'
80+
indent: 'off',
81+
'@typescript-eslint/indent': [
82+
'error',
83+
'tab',
84+
{
85+
SwitchCase: 1
86+
}
87+
],
88+
'@typescript-eslint/interface-name-prefix': [
89+
'error',
90+
'never'
91+
],
92+
'@typescript-eslint/member-delimiter-style': [
93+
'error',
94+
{
95+
multiline: {
96+
delimiter: 'semi',
97+
requireLast: true
98+
},
99+
singleline: {
100+
delimiter: 'semi',
101+
requireLast: true
102+
}
103+
}
104+
],
105+
'@typescript-eslint/member-naming': [
106+
'error',
107+
{
108+
private: '^_'
109+
}
110+
],
111+
'@typescript-eslint/member-ordering': 'error',
112+
'@typescript-eslint/no-angle-bracket-type-assertion': 'error',
113+
'@typescript-eslint/no-array-constructor': 'error',
114+
'@typescript-eslint/no-empty-interface': 'error',
115+
116+
// The `ban-types` rule handles this better
117+
// '@typescript-eslint/no-explicit-any': 'error',
118+
119+
'@typescript-eslint/no-extraneous-class': 'error',
120+
'@typescript-eslint/no-inferrable-types': 'error',
121+
'@typescript-eslint/no-misused-new': 'error',
122+
'@typescript-eslint/no-namespace': 'error',
123+
'@typescript-eslint/no-non-null-assertion': 'error',
124+
'@typescript-eslint/no-object-literal-type-assertion': 'error',
125+
'@typescript-eslint/no-this-alias': [
126+
'error',
127+
{
128+
allowDestructuring: true,
129+
}
130+
],
131+
'@typescript-eslint/no-triple-slash-reference': 'error',
132+
'@typescript-eslint/no-type-alias': 'error',
133+
'@typescript-eslint/no-unused-vars': 'error',
134+
'@typescript-eslint/no-var-requires': 'error',
135+
'@typescript-eslint/prefer-interface': 'error',
136+
'@typescript-eslint/prefer-namespace-keyword': 'error',
137+
'@typescript-eslint/type-annotation-spacing': 'error'
53138
}
54139
};

package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,15 @@
4242
"simple"
4343
],
4444
"devDependencies": {
45-
"ava": "^0.25.0",
46-
"eslint": "^5.9.0",
47-
"eslint-plugin-typescript": "^0.13.0",
48-
"temp-write": "^3.1.0",
49-
"typescript": "^3.1.6",
50-
"typescript-eslint-parser": "^20.1.1"
45+
"@typescript-eslint/eslint-plugin": "^1.0.0",
46+
"ava": "^1.1.0",
47+
"eslint": "^5.12.1",
48+
"temp-write": "^3.4.0",
49+
"typescript": "^3.2.4"
5150
},
5251
"peerDependencies": {
53-
"eslint": ">=5.9.0",
54-
"eslint-plugin-typescript": ">=0.13.0",
55-
"typescript": ">=3.1.6",
56-
"typescript-eslint-parser": ">=20.1.1"
52+
"@typescript-eslint/eslint-plugin": ">=1.0.0",
53+
"eslint": ">=5.12.1",
54+
"typescript": ">=3.2.4"
5755
}
5856
}

readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# eslint-config-xo-typescript [![Build Status](https://travis-ci.org/xojs/eslint-config-xo-typescript.svg?branch=master)](https://travis-ci.org/xojs/eslint-config-xo-typescript)
22

3-
> ESLint [shareable config](http://eslint.org/docs/developer-guide/shareable-configs.html) for TypeScript to be used with [eslint-config-xo](https://github.com/xojs/eslint-config-xo)
3+
> ESLint [shareable config](https://eslint.org/docs/developer-guide/shareable-configs.html) for TypeScript to be used with [eslint-config-xo](https://github.com/xojs/eslint-config-xo)
44
55

66
## Install
77

88
```
9-
$ npm install --save-dev eslint-config-xo eslint-config-xo-typescript typescript-eslint-parser eslint-plugin-typescript
9+
$ npm install --save-dev eslint-config-xo eslint-config-xo-typescript @typescript-eslint/eslint-plugin
1010
```
1111

1212

@@ -43,7 +43,7 @@ Or to .eslintrc:
4343
### Use with XO
4444

4545
```
46-
$ npm install --save-dev eslint-config-xo-typescript typescript-eslint-parser eslint-plugin-typescript
46+
$ npm install --save-dev eslint-config-xo-typescript @typescript-eslint/eslint-plugin
4747
```
4848

4949
```json

test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ function runEslint(string, config) {
1616

1717
test('main', t => {
1818
const errors = runEslint('const foo: number = 5;', config);
19-
t.true(hasRule(errors, 'typescript/no-inferrable-types'));
19+
t.true(hasRule(errors, '@typescript-eslint/no-inferrable-types'));
2020
});

0 commit comments

Comments
 (0)