-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
eslint.config.js
120 lines (116 loc) · 3.25 KB
/
eslint.config.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
// @ts-check
// @ts-expect-error
import { FlatCompat } from '@eslint/eslintrc';
// @ts-expect-error
import js from '@eslint/js';
// eslint-disable-next-line @typescript-eslint/naming-convention
const __dirname = new URL('.', import.meta.url).pathname;
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
/** @type {import('eslint').Linter.FlatConfig[]} */
// eslint-disable-next-line import/no-default-export
export default [
{
ignores: [
'**/dist',
'**/*.css.d.ts',
'packages/example',
'docs/how-does-definition-jumps-work',
'packages/happy-css-modules/bin/**',
],
},
// NOTE: This is a hack that allows eslint-plugin-import to work with flat config.
// ref: https://github.com/import-js/eslint-plugin-import/issues/2556#issuecomment-1419518561
{
languageOptions: {
parserOptions: {
// Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions`
// This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error
ecmaVersion: 'latest',
sourceType: 'module',
},
},
settings: {
// This will do the trick
'import/parsers': {
espree: ['.js', '.cjs', '.mjs', '.jsx'],
},
},
},
...compat.extends('@mizdra/mizdra', '@mizdra/mizdra/+typescript', '@mizdra/mizdra/+prettier'),
...compat.env({
node: true,
}),
{
rules: {
// disable because this rule do not support ESM in TypeScript.
// ref: https://github.com/import-js/eslint-plugin-import/issues/2170
'import/no-unresolved': 'off',
// MEMO: It doesn't work for some reason, so disable it...
// 'import/no-extraneous-dependencies': [
// 'error',
// {
// includeTypes: true,
// packageDir: [
// __dirname,
// join(__dirname, 'happy-css-modules'),
// join(__dirname, 'stylelint-happy-css-modules'),
// join(__dirname, 'example'),
// ],
// },
// ],
'import/no-extraneous-dependencies': 'off',
'no-console': 2,
'no-use-before-define': 0,
},
},
{
files: ['**/*.{ts,tsx,cts,mts}'],
languageOptions: {
parserOptions: {
project: ['tsconfig.json', 'example/tsconfig.json'],
},
},
rules: {
'@typescript-eslint/no-unused-vars': [2, { argsIgnorePattern: '^_' }],
'@typescript-eslint/consistent-type-imports': [2, { disallowTypeAnnotations: false }],
'@typescript-eslint/no-non-null-assertion': 0,
},
},
...compat.env({
files: ['src/test-util/**/*.{ts,tsx,cts,mts}', '*.test.{ts,tsx,cts,mts}'],
env: {
jest: true,
},
rules: {
'no-console': 0,
},
}),
{
files: ['packages/happy-css-modules/**'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
'./*/*',
'../*/*',
'!./*.js',
'!../*.js',
'!./*/index.js',
'!../*/index.js',
'!./*/util.js',
'!../*/util.js',
'!./library/*',
'!../library/*',
'!./test-util/*',
'!../test-util/*',
],
},
],
},
},
];