-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
143 lines (138 loc) · 4.54 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
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
140
141
142
143
// @ts-check
import {dirname} from 'path';
import {fileURLToPath} from 'url';
import {FlatCompat} from '@eslint/eslintrc';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
});
// eslint-disable-next-line import/no-anonymous-default-export
export default [
...compat.config({
plugins: ['prettier', '@typescript-eslint'],
extends: [
'next/core-web-vitals',
'next/typescript',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'prettier',
],
rules: {
'prettier/prettier': [
'error',
{
semi: true,
singleQuote: true,
jsxSingleQuote: false,
trailingComma: 'es5',
bracketSpacing: false,
jsxBracketSameLine: true,
arrowParens: 'avoid',
},
],
'@typescript-eslint/no-empty-function': [
'error',
{allow: ['arrowFunctions']},
],
'@typescript-eslint/ban-ts-comment': 1,
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'no-const-assign': 'error',
/** Restrict imports from devDependencies since they are not included in library build. peerDependencies are ok */
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
peerDependencies: true,
},
],
/**
* Enforce import order with empty lines between import group
* @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
*/
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
['parent', 'sibling', 'index'],
],
pathGroups: [
{
pattern: '@/**',
group: 'internal',
},
],
'newlines-between': 'always',
},
],
/**
* Disallow combined module and type imports like this `import React, {FC} from 'react'`.
* Eslint will try to split into type and module imports instead
* @see https://typescript-eslint.io/rules/consistent-type-imports/
*/
'@typescript-eslint/consistent-type-imports': 'error',
'import/no-cycle': 'error',
},
}),
/* Allow devDependencies imports for tests and config files */
{
files: [
'**/*.spec.*',
'**/testUtils/*.{js,jsx,ts,tsx}',
'*/*.{js,jsx,ts,tsx}',
'**/setupTests.ts',
'*.config.{js,ts,mjs}',
'**/env/**/*.*',
],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
peerDependencies: true,
},
],
},
},
/* Disable `environment` directory imports for library files */
{
files: ['src/lib/**/*.{js,jsx,ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/environment/**'],
message:
'Imports from environment directory are forbidden in the library files.',
},
],
},
],
},
},
/* Disable `template` directory imports for all files */
{
files: ['src/**/*.{js,jsx,ts,tsx}'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['**/templates/**'],
message: 'Imports from templates directory are forbidden.',
},
],
},
],
},
},
{
ignores: ['**/*.{snap,css,jpg}'],
},
];