-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
149 lines (131 loc) · 4.04 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* The airbnb lint configuration is out of date, it refers to rules which have been
* removed. On extending 'airbnb-angular' we get lots of errors such as
* Definition for rule '@typescript-eslint/class-name-casing' was not found
* Definition for rule '@typescript-eslint/camelcase' was not found
*
* Instead we have copied code directly from the airbnb angular eslint file into this file
* the bits we have copied are the following
* - the 2 constants baseStyleRules & dangleRules
* - some of the rules in the rules section
* - the overrides section
*
* airbnb eslint file for angular:
* https://github.com/efoken/eslint-config-airbnb-angular/blob/master/rules/angular.js
*/
const baseStyleRules = require('eslint-config-airbnb-base/rules/style').rules;
const dangleRules = baseStyleRules['no-underscore-dangle'];
module.exports = {
env: {
browser: true,
// es2021: true, // Environment key "es2021" is unknown
node: true,
},
extends: [
// 'airbnb-angular' // Oct 2020: airbnb needs updating, so we can not use it yet
'eslint-config-airbnb-base',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
],
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.component'],
},
},
},
// rules for all files (*.ts are overritten below)
//
rules: {
// our own rules
'linebreak-style': 0,
'no-console': 'off',
'no-empty-function': ['error', { allow: ['constructors'] }],
'@typescript-eslint/naming-convention': 'warn',
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
// airbnb angular rules
'class-methods-use-this': 'off',
'no-underscore-dangle': [
dangleRules[0],
{
...dangleRules[1],
allow: dangleRules[1].allow.concat(['__karma__']),
},
],
'import/default': 'error',
'import/namespace': 'error',
'import/imports-first': 'error',
},
// override the above details for .ts files (copied from airbnb angular)
overrides: [
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
'no-unused-vars': ['error', { vars: 'all', args: 'none', ignoreRestSiblings: true }],
'no-useless-constructor': 'off',
// IMPORT
'import/prefer-default-export': 'off',
// TYPESCRIPT
'@typescript-eslint/adjacent-overload-signatures': 'error',
// '@typescript-eslint/class-name-casing': 'error', // no longer valid
'@typescript-eslint/member-delimiter-style': 'error',
'@typescript-eslint/member-ordering': [
'error',
{
default: [
'public-field',
'private-field',
'constructor',
'public-method',
'private-method',
],
},
],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ vars: 'all', args: 'none', ignoreRestSiblings: true },
],
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": []
},
],
},
},
{
files: ['*.{spec,e2e-spec}.ts', 'protractor.conf.js'],
env: {
jasmine: true,
node: true,
},
},
],
};