generated from UCLA-Creative-Labs/open-source-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.build.js
139 lines (112 loc) · 3.83 KB
/
.eslintrc.build.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
module.exports = {
env: {
es2020: true,
},
extends: [
'eslint:recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
project: './tsconfig.json',
},
plugins: [
'import',
'@typescript-eslint',
],
rules: {
'linebreak-style': [ 'error', 'unix' ],
// Always add a trailing new line to the end of a file (clean diffs)
'eol-last': [ 'error', 'unix' ],
'@typescript-eslint/no-require-imports': [ 'error' ],
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
// Arugements can be typed as any
'@typescript-eslint/explicit-module-boundary-types': [
'warn',
{ allowArgumentsExplicitlyTypedAsAny: true },
],
// Remove default disallowal of any type
'@typescript-eslint/no-explicit-any': 'off',
// 2 space indentation
'@typescript-eslint/indent': [ 'error', 2 ],
// Style
'quotes': [ 'error', 'single', { avoidEscape: true } ],
// ensures clean diffs, see https://medium.com/@nikgraf/why-you-should-enforce-dangling-commas-for-multiline-statements-d034c98e36f8
'comma-dangle': [ 'error', 'always-multiline' ],
// Require all imported dependencies are actually declared in package.json
'import/no-extraneous-dependencies': [
'error',
{
optionalDependencies: false, // Disallow importing optional dependencies (those shouldn't be in use in the project)
peerDependencies: false, // Disallow importing peer dependencies (that aren't also direct dependencies)
},
],
// Require all imported libraries actually resolve (!!required for import/no-extraneous-dependencies to work!!)
'import/no-unresolved': [ 'error' ],
// Require an ordering on all imports
'import/order': ['warn', {
groups: ['builtin', 'external'],
alphabetize: { order: 'asc', caseInsensitive: true },
}],
// Cannot import from the same module twice
'no-duplicate-imports': ['error'],
// Cannot shadow names
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
// Required spacing in property declarations (copied from TSLint, defaults are good)
'key-spacing': ['error'],
// Require semicolons
'semi': ['error', 'always'],
// Don't unnecessarily quote properties
'quote-props': ['error', 'consistent-as-needed'],
// No multiple empty lines
'no-multiple-empty-lines': ['error'],
// Max line lengths
'max-len': ['error', {
code: 120,
ignoreUrls: true, // Most common reason to disable it
ignoreStrings: true, // These are not fantastic but necessary for error messages
ignoreTemplateLiterals: true,
ignoreComments: true,
ignoreRegExpLiterals: true,
}],
// One of the easiest mistakes to make
'@typescript-eslint/no-floating-promises': ['error'],
// Don't leave log statements littering the premises!
'no-console': ['error'],
// Useless diff results
'no-trailing-spaces': ['error'],
// Must use foo.bar instead of foo['bar'] if possible
'dot-notation': ['error'],
// Are you sure | is not a typo for || ?
'no-bitwise': ['error'],
// Member ordering
'@typescript-eslint/member-ordering': ['error', {
default: [
'public-static-field',
'public-static-method',
'protected-static-field',
'protected-static-method',
'private-static-field',
'private-static-method',
'field',
// Constructors
'constructor', // = ['public-constructor', 'protected-constructor', 'private-constructor']
// Methods
'method',
],
}],
},
};