-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
134 lines (124 loc) · 4.79 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const fs = require('fs');
module.exports = {
root: true,
// Use the typescript-eslint parser
parser: '@typescript-eslint/parser',
// Enable eslint and typescript-eslint
plugins: ['eslint-plugin', '@typescript-eslint', 'jasmine'],
env: {
es6: true,
node: true,
jasmine:true
},
parserOptions: {
sourceType: 'module',
project: getProjectFile(),
createDefaultProgram: true,
ecmaFeatures: {
ecmaVersion: 2017,
jsx: false,
},
noWatch: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
/**
* Use `prettier` to override default formatting related rules
* See https://github.com/prettier/eslint-config-prettier
*/
'prettier',
'prettier/@typescript-eslint',
],
rules: {
'prefer-const': 'error',
'no-mixed-operators': 'off',
'no-console': 'off',
// 'no-undef': 'off',
'no-inner-declarations': 'off',
// TypeScript allows method overloading
'no-dupe-class-members': 'off',
'no-useless-escape': 'off',
// TypeScript allows the same name for namespace and function
'no-redeclare': 'off',
// Avoid promise rewrapping
// https://exploringjs.com/es2016-es2017/ch_async-functions.html#_returned-promises-are-not-wrapped
'no-return-await': 'error',
'no-array-constructor': 'error',
/**
* TypeScript specific rules
* See https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
*/
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-angle-bracket-type-assertion': 'off',
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-triple-slash-reference': 'off',
'@typescript-eslint/no-empty-interface': 'off',
/**
* The following rules are enforced to support legacy tslint configuration
*/
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.md
'@typescript-eslint/adjacent-overload-signatures': 'error', // tslint:adjacent-overload-signatures
'@typescript-eslint/prefer-for-of': 'error', // tslint:prefer-for-of
'@typescript-eslint/unified-signatures': 'error', // tslint:unified-signatures
'@typescript-eslint/no-explicit-any': 'off', // tslint:no-any
'no-unused-labels': 'error', // tslint:label-position
'no-caller': 'error', // tslint:no-arg
'no-new-wrappers': 'error', // tslint:no-construct
// because of the flatiron plugin
'no-invalid-this': 'off',
'@typescript-eslint/no-this-alias':'off',
'@typescript-eslint/no-misused-new': 'error',
'no-shadow': 'error', // tslint:no-shadowed-variable
'no-throw-literal': 'error', // tslint:no-string-throw
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'none', // none - do not check arguments
varsIgnorePattern: 'inject|(\\w+)Bindings',
ignoreRestSiblings: false,
},
], // tslint:no-unused-variable
'no-unused-expressions': 'error', // tslint:no-unused-expression
'no-var': 'error', // tslint:no-var-keyword
eqeqeq: ['error', 'smart'], // tslint:triple-equals: [true, 'allow-null-check', 'allow-undefined-check'],
'@typescript-eslint/await-thenable': 'error', // tslint:await-promise: [true, 'PromiseLike', 'RequestPromise'],
'@typescript-eslint/no-floating-promises': 'off',
'no-void': 'error', // tslint:no-void-expression: [true, 'ignore-arrow-function-shorthand'],
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/return-await': 'error',
},
overrides: [
{
files: ['**/*.js'],
rules: {
'@typescript-eslint/prefer-optional-chain': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
},
},
],
};
/**
* Detect tsconfig file
*/
function getProjectFile() {
if (fs.existsSync('./tsconfig.build.json')) return './tsconfig.build.json';
if (fs.existsSync('./tsconfig.json')) return './tsconfig.json';
return undefined;
}