Skip to content

Commit c941ab1

Browse files
authoredAug 31, 2020
fix: reduce type check (#54)
1 parent e9ddf88 commit c941ab1

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed
 

‎lib/rules/typescript.js

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

19+
'@typescript-eslint/explicit-module-boundary-types': 'off',
20+
'@typescript-eslint/ban-types': [
21+
'error',
22+
{
23+
types: {
24+
'{}': false,
25+
object: false,
26+
},
27+
extendDefaults: true,
28+
},
29+
],
30+
1931
/**
2032
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
2133
*/
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let bba: {};
2+
let cca: object;
3+
let cbc: string;
4+
5+
(function() {
6+
bba = {};
7+
cca = {};
8+
cbc = '123123';
9+
})();
10+
11+
console.info(bba, cca, cbc);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let bba: {};
2+
let cca: Object;
3+
let cbc: String;
4+
5+
(function() {
6+
bba = {};
7+
cca = {};
8+
cbc = '123123';
9+
})();
10+
11+
console.info(bba, cca, cbc);

‎test/ts.test.js

+17
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,21 @@ describe('test/ts.test.js', () => {
202202
.end();
203203
});
204204
});
205+
206+
describe('ban-types', () => {
207+
it('should success', () => {
208+
return coffee.spawn('eslint', [ './ban-types/correct.ts' ], { cwd })
209+
.debug()
210+
.expect('code', 0)
211+
.end();
212+
});
213+
214+
it('should fail', () => {
215+
return coffee.spawn('eslint', [ './ban-types/not-correct.ts' ], { cwd })
216+
// .debug()
217+
.expect('code', 1)
218+
.expect('stdout', /@typescript-eslint\/ban-types/)
219+
.end();
220+
});
221+
});
205222
});

0 commit comments

Comments
 (0)
Please sign in to comment.