-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy patheslint.config.mjs
More file actions
130 lines (129 loc) · 4 KB
/
Copy patheslint.config.mjs
File metadata and controls
130 lines (129 loc) · 4 KB
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
import js from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import { defineConfig } from 'eslint/config';
import importPlugin from 'eslint-plugin-import';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default defineConfig([
js.configs.recommended,
{
ignores: [
'**/node_modules/**',
'**/build/**',
'**/ts_build/**',
'packages/insight/**',
]
},
{
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
plugins: { js, import: importPlugin },
extends: ['js/recommended'],
languageOptions: {
ecmaVersion: 2020,
globals: {
...globals.node,
'NodeJS': 'readonly',
'BufferEncoding': 'readonly',
},
parserOptions: {
impliedStrict: true
}
}
},
tseslint.configs.recommended,
{ // TypeScript files
files: ['**/*.{ts,mts,cts}'],
plugins: {
'@typescript-eslint': tseslint.plugin,
'@stylistic': stylistic,
},
rules: {
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
}
},
{
plugins: {
'@stylistic': stylistic,
},
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
'prefer-const': 'warn',
'no-var': 'warn',
'no-undef': 'error',
'no-async-promise-executor': 'off',
'semi': ['error', 'always'],
'no-case-declarations': 'off',
'no-bitwise': 'error',
'spaced-comment': ['error', 'always', { exceptions: ['-', '+'] }],
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/indent': ['error', 2, { SwitchCase: 1 }],
'@stylistic/member-delimiter-style': ['error', {
multiline: {
delimiter: 'semi',
requireLast: true
},
singleline: {
delimiter: 'semi',
requireLast: false
}
}],
'object-curly-spacing': ['error', 'always'],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
'comma-spacing': ['error', { before: false, after: true }],
'space-before-blocks': ['error', 'always'],
'keyword-spacing': ['error', { before: true, after: true }],
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
'no-restricted-syntax': [
'error',
{
selector: 'CallExpression[callee.type="MemberExpression"][callee.property.name="forEach"]',
message: 'Use for...of loop or array methods like map/filter instead of forEach'
}
],
'sort-imports': ['error', {
ignoreDeclarationSort: true, // rule cannot be auto-fixed
ignoreMemberSort: false // import { b, a } from 'X' -> import { a, b } from 'X'
}],
'import/order': ['error', {
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
'newlines-between': 'never',
alphabetize: { order: 'asc', caseInsensitive: false }
}],
'import/newline-after-import': 'error'
}
},
{
files: [
'packages/bitcore-lib*/**/*.js',
'packages/bitcore-p2p*/**/*.js',
'packages/bitcore-tss/**/*.js',
],
languageOptions: { sourceType: 'commonjs' },
rules: {
'@typescript-eslint/no-require-imports': 'warn',
'no-bitwise': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
}
},
// Test files -- needs to be last so it can override other settings
{
files: ['**/test/**/*.{ts,js}'],
languageOptions: {
globals: {
...globals.mocha
}
},
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-this-alias': 'warn',
'@typescript-eslint/no-unused-expressions': 'off',
'sort-imports': 'off',
'import/order': 'off'
}
}
]);