Skip to content

Commit 4215571

Browse files
authoredAug 28, 2020
feat: upgrade typescript-eslint (#53)
1 parent 483777e commit 4215571

File tree

11 files changed

+134
-6
lines changed

11 files changed

+134
-6
lines changed
 

‎.github/workflows/nodejs.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ${{ matrix.os }}
16+
17+
strategy:
18+
matrix:
19+
node-version: [10.x, 12.x]
20+
os: [ubuntu-latest, windows-latest, macos-latest]
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
- run: npm i -g npminstall && npminstall
29+
- run: npm run ci
30+
env:
31+
CI: true

‎.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sudo: false
1+
22
language: node_js
33
node_js:
44
- '10'

‎lib/rules/typescript.js

+15
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ module.exports = {
1616
markers: [ '*!', '/' ],
1717
}],
1818

19+
/**
20+
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
21+
*/
22+
'no-use-before-define': 'off',
23+
'@typescript-eslint/no-use-before-define': [ 'error', {
24+
functions: false,
25+
classes: true,
26+
}],
27+
28+
/**
29+
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
30+
*/
31+
'no-useless-constructor': 'off',
32+
'@typescript-eslint/no-useless-constructor': [ 'error' ],
33+
1934
/**
2035
* An empty interface is equivalent to its supertype
2136
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-interface.md

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"lib"
1313
],
1414
"dependencies": {
15-
"@typescript-eslint/eslint-plugin": "^2.0.0",
16-
"@typescript-eslint/parser": "^2.0.0",
15+
"@typescript-eslint/eslint-plugin": "^3.0.0",
16+
"@typescript-eslint/parser": "^3.0.0",
1717
"babel-eslint": "^8.2.6",
1818
"eslint-plugin-eggache": "^1.0.0",
1919
"eslint-plugin-import": "^2.14.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class MyClass {
2+
constructor(
3+
public a: number,
4+
public b: string,
5+
) {}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export class MyClass {
2+
constructor() {}
3+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
interface IFSMTransition<T extends string> {
2+
name: string;
3+
from: T[];
4+
to: T;
5+
}
6+
7+
type IFSMTransitions<T extends string> = IFSMTransition<T>[];
8+
9+
export default IFSMTransitions;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class ABC {
2+
3+
}
4+
5+
const instance = new ABC();
6+
testABC(instance);
7+
8+
function testABC(abc: ABC) {
9+
console.info(abc);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const instance = new ABC();
2+
testABC(instance);
3+
4+
function testABC(abc: ABC) {
5+
console.info(abc);
6+
}
7+
8+
class ABC {
9+
10+
}

‎test/fixtures/ts-app/semi/semi.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const abc = 123;
2+
export interface SPI {}

‎test/ts.test.js

+46-3
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe('test/ts.test.js', () => {
100100

101101
it('should success with members', () => {
102102
return coffee.spawn('eslint', [ './align/members.ts' ], { cwd })
103-
.debug()
103+
// .debug()
104104
.expect('code', 0)
105105
.end();
106106
});
@@ -122,15 +122,15 @@ describe('test/ts.test.js', () => {
122122

123123
it('should fail with parameters', () => {
124124
return coffee.spawn('eslint', [ './align/parameters-error.ts' ], { cwd })
125-
.debug()
125+
// .debug()
126126
.expect('stdout', /indent/)
127127
.expect('code', 1)
128128
.end();
129129
});
130130

131131
it('should success with statements', () => {
132132
return coffee.spawn('eslint', [ './align/statements.ts' ], { cwd })
133-
.debug()
133+
// .debug()
134134
.expect('code', 0)
135135
.end();
136136
});
@@ -159,4 +159,47 @@ describe('test/ts.test.js', () => {
159159
.end();
160160
});
161161
});
162+
163+
describe('no-useless-constructor', () => {
164+
it('should success', () => {
165+
return coffee.spawn('eslint', [ './constructor/correct.ts' ], { cwd })
166+
// .debug()
167+
.expect('code', 0)
168+
.end();
169+
});
170+
171+
it('should fail', () => {
172+
return coffee.spawn('eslint', [ './constructor/not-correct.ts' ], { cwd })
173+
// .debug()
174+
.expect('code', 1)
175+
.expect('stdout', /@typescript-eslint\/no-useless-constructor/)
176+
.end();
177+
});
178+
});
179+
180+
describe('no-use-before-define', () => {
181+
it('should success', () => {
182+
return coffee.spawn('eslint', [ './no-use-before-define/correct.ts' ], { cwd })
183+
// .debug()
184+
.expect('code', 0)
185+
.end();
186+
});
187+
188+
it('should fail', () => {
189+
return coffee.spawn('eslint', [ './no-use-before-define/not-correct.ts' ], { cwd })
190+
// .debug()
191+
.expect('code', 1)
192+
.expect('stdout', /@typescript-eslint\/no-use-before-define/)
193+
.end();
194+
});
195+
});
196+
197+
describe('no-undef', () => {
198+
it('should success', () => {
199+
return coffee.spawn('eslint', [ './no-undef/correct.ts' ], { cwd })
200+
// .debug()
201+
.expect('code', 0)
202+
.end();
203+
});
204+
});
162205
});

0 commit comments

Comments
 (0)
Please sign in to comment.