-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patheslint.config.mjs
90 lines (81 loc) · 2.24 KB
/
eslint.config.mjs
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
// @ts-check
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
import * as importPlugin from 'eslint-plugin-import';
import tseslint from 'typescript-eslint';
const __dirname = dirname(fileURLToPath(import.meta.url));
const compat = new FlatCompat({
baseDirectory: __dirname,
});
export default tseslint.config(
{
files: ['src/**/*.?(c|m)js', '*.?(c|m)js', 'src/**/*.ts'],
ignores: ['index.js'],
extends: [
eslint.configs.recommended,
...compat.extends('plugin:eslint-comments/recommended'),
...compat.extends('plugin:import/typescript'),
],
plugins: {
'eslint-comments': eslintCommentsPlugin,
'import': importPlugin,
},
rules: {
'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }],
'eslint-comments/no-unused-disable': 'error',
'import/order': [
'error',
{
'newlines-between': 'always',
'alphabetize': { order: 'asc' },
},
],
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
ignoreCase: true,
},
],
},
},
{
files: ['src/**/*.ts'],
extends: [
//...tseslint.configs.recommended,
//...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
parserOptions: {
project: './tsconfig.test.json',
tsconfigRootDir: __dirname,
},
},
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowBoolean: true,
allowNullish: true,
allowNumber: true,
},
],
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
},
],
},
},
prettierConfig,
);