Skip to content

Commit 2591d1d

Browse files
sang4lvwhxaxes
authored andcommittedJan 20, 2020
fix: unused vars rule (#50)
* fix: unused-vars is now valid * chore: update CI generated config * feat: turn on unused-vars check * chore: force CI refresh * feat: unused-vars should check local variables only * fix: update trailing comma test case
1 parent 749e46e commit 2591d1d

11 files changed

+31
-12
lines changed
 

‎.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- '8'
54
- '10'
65
- '12'
76
before_install:

‎appveyor.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
environment:
22
matrix:
3-
- nodejs_version: '8'
43
- nodejs_version: '10'
54
- nodejs_version: '12'
65

‎lib/rules/typescript.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ module.exports = {
2626
* Variables that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring
2727
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
2828
*/
29-
'@typescript-eslint/no-unused-vars': 'off',
29+
'no-unused-vars': 'off',
30+
'@typescript-eslint/no-unused-vars': [ 'error', {
31+
vars: 'local',
32+
args: 'after-used',
33+
}],
3034

3135
/**
3236
* Enforce camelCase naming convention
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
setTimeout(() => {
2-
2+
console.log('');
33
}, 200);
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const foo = [
1+
export const foo = [
22
1,
33
2,
44
];
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
function bar(
22
a: string,
33
b: string
4-
) {}
4+
) {
5+
console.log(a, b);
6+
}
7+
8+
export { bar };

‎test/fixtures/ts-app/align/parameters.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ function bar(
44
) {
55
console.info(a, b);
66
}
7+
8+
export { bar };
+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
const foo1 = 1;
22
const bar1 = 2;
3+
4+
export { foo1, bar1 };

‎test/fixtures/ts-app/comma/trailing-comma.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ function foo2(
1616
}
1717

1818
import {
19-
a,
20-
b,
21-
} from 'egg';
19+
fork,
20+
spawn,
21+
} from 'coffee';
2222

2323
export {
24-
a,
25-
b,
26-
} from 'egg';
24+
Rule,
25+
} from 'coffee';
26+
27+
export { foo2, fork, spawn };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import { abc } from './semi/semi';

‎test/ts.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,12 @@ describe('test/ts.test.js', () => {
151151
.expect('code', 0)
152152
.end();
153153
});
154+
155+
it('should success with unused variables', () => {
156+
return coffee.spawn('eslint', [ './reference/unused-vars.ts' ], { cwd })
157+
// .debug()
158+
.expect('code', 1)
159+
.end();
160+
});
154161
});
155162
});

0 commit comments

Comments
 (0)
Please sign in to comment.