-
Notifications
You must be signed in to change notification settings - Fork 385
Expand file tree
/
Copy patheslint.config.base.js
More file actions
79 lines (76 loc) · 2.37 KB
/
eslint.config.base.js
File metadata and controls
79 lines (76 loc) · 2.37 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
// @ts-check
'use strict';
const tseslint = require('typescript-eslint');
const stylistic = require('@stylistic/eslint-plugin');
const globals = require('globals');
/**
* Creates an ESLint flat config array for a TypeScript package.
*
* @param {string[]} projects - tsconfig project paths (relative to the package root)
* @param {string[]} [ignores] - additional paths/globs to ignore
* @param {Record<string, unknown>} [extraRules] - package-specific rule overrides
* @returns {import('eslint').Linter.Config[]}
*/
function createConfig(projects, ignores, extraRules) {
return tseslint.config(
{
ignores: ['lib/**', 'dist/**', 'node_modules/**', ...(ignores ?? [])],
},
{
files: ['**/*.ts'],
extends: [tseslint.configs.base],
languageOptions: {
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
project: projects,
tsconfigRootDir: process.cwd(),
},
globals: {
...globals.node,
},
},
plugins: {
'@stylistic': stylistic,
},
rules: {
'@stylistic/semi': 'error',
'@stylistic/member-delimiter-style': ['error', {
multiline: { delimiter: 'semi', requireLast: true },
singleline: { delimiter: 'semi', requireLast: false },
multilineDetection: 'brackets',
}],
'@stylistic/indent': ['warn', 'tab', { SwitchCase: 1 }],
'@stylistic/no-extra-semi': 'warn',
'@stylistic/quotes': ['error', 'single', { allowTemplateLiterals: true }],
'@typescript-eslint/no-floating-promises': 'error',
'curly': 'warn',
'eqeqeq': 'error',
'constructor-super': 'warn',
'prefer-const': ['warn', { destructuring: 'all' }],
'no-caller': 'warn',
'no-case-declarations': 'warn',
'no-debugger': 'warn',
'no-duplicate-case': 'warn',
'no-duplicate-imports': 'warn',
'no-eval': 'warn',
'no-async-promise-executor': 'warn',
'no-new-wrappers': 'warn',
'no-redeclare': 'off',
'no-sparse-arrays': 'warn',
'no-throw-literal': 'warn',
'no-unsafe-finally': 'warn',
'no-unused-labels': 'warn',
'no-restricted-globals': ['warn', 'name', 'length', 'event', 'closed', 'external', 'status', 'origin', 'orientation', 'context'],
'no-var': 'warn',
'@typescript-eslint/naming-convention': ['warn', {
selector: 'class',
format: ['PascalCase'],
leadingUnderscore: 'allow',
}],
...extraRules,
},
},
);
}
module.exports = { createConfig };