@tarsilla/eslint-config 0.1.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/library/index.cjs +1 -1
- package/lib/library/index.cjs.map +1 -1
- package/lib/library/index.mjs +1 -1
- package/lib/library/index.mjs.map +1 -1
- package/lib/next/index.cjs +1 -1
- package/lib/next/index.cjs.map +1 -1
- package/lib/next/index.mjs +1 -1
- package/lib/next/index.mjs.map +1 -1
- package/lib/react/index.cjs +1 -1
- package/lib/react/index.cjs.map +1 -1
- package/lib/react/index.mjs +1 -1
- package/lib/react/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/commons/all.ts +18 -0
- package/src/commons/imports.ts +44 -0
- package/src/commons/index.ts +9 -0
- package/src/commons/javascript.ts +9 -0
- package/src/commons/jest.ts +10 -0
- package/src/commons/prettier.ts +31 -0
- package/src/commons/react-hooks.ts +17 -0
- package/src/commons/sortImports.ts +17 -0
- package/src/commons/typescript.ts +16 -0
- package/src/commons/unusedImports.ts +25 -0
- package/src/library/eslintLibraryConfig.ts +19 -114
- package/src/next/eslintNextConfig.ts +23 -113
- package/src/react/eslintReactConfig.ts +24 -136
|
@@ -2,16 +2,19 @@ import { dirname } from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
|
|
4
4
|
import { FlatCompat } from '@eslint/eslintrc';
|
|
5
|
-
import js from '@eslint/js';
|
|
6
5
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
7
|
-
import
|
|
8
|
-
import prettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
9
|
-
import reactPlugin from 'eslint-plugin-react';
|
|
10
|
-
import reactHooks from 'eslint-plugin-react-hooks';
|
|
11
|
-
import unusedImports from 'eslint-plugin-unused-imports';
|
|
12
|
-
import globalsImp from 'globals';
|
|
13
|
-
import { config, configs } from 'typescript-eslint';
|
|
6
|
+
import { config } from 'typescript-eslint';
|
|
14
7
|
|
|
8
|
+
import {
|
|
9
|
+
allConfig,
|
|
10
|
+
javascriptConfig,
|
|
11
|
+
jestConfig,
|
|
12
|
+
prettierConfig,
|
|
13
|
+
reactHooksConfig,
|
|
14
|
+
sortImportsConfig,
|
|
15
|
+
typescriptConfig,
|
|
16
|
+
unusedImportsConfig,
|
|
17
|
+
} from '../commons/index.js';
|
|
15
18
|
import { EslintOptions } from '../types/index.js';
|
|
16
19
|
|
|
17
20
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -21,13 +24,13 @@ const compat = new FlatCompat({
|
|
|
21
24
|
baseDirectory: __dirname,
|
|
22
25
|
});
|
|
23
26
|
|
|
24
|
-
const globals = globalsImp as Record<string, Record<string, boolean>>;
|
|
25
|
-
|
|
26
27
|
function eslintNextConfig({ ignores }: EslintOptions): TSESLint.FlatConfig.ConfigArray {
|
|
27
28
|
return config(
|
|
28
|
-
|
|
29
|
+
{
|
|
30
|
+
ignores,
|
|
31
|
+
},
|
|
29
32
|
...compat.config({
|
|
30
|
-
extends: ['next/core-web-vitals'],
|
|
33
|
+
extends: ['next/core-web-vitals', 'next/typescript'],
|
|
31
34
|
rules: {
|
|
32
35
|
'import/order': [
|
|
33
36
|
'error',
|
|
@@ -55,107 +58,14 @@ function eslintNextConfig({ ignores }: EslintOptions): TSESLint.FlatConfig.Confi
|
|
|
55
58
|
],
|
|
56
59
|
},
|
|
57
60
|
}),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
parserOptions: {
|
|
67
|
-
ecmaVersion: 'latest',
|
|
68
|
-
sourceType: 'module',
|
|
69
|
-
project: true,
|
|
70
|
-
tsconfigRootDir: './',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
rules: {
|
|
74
|
-
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
75
|
-
'@typescript-eslint/no-explicit-any': 'error',
|
|
76
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
files: ['**/*.{jsx,tsx}'],
|
|
81
|
-
...reactPlugin.configs.flat.recommended,
|
|
82
|
-
...reactPlugin.configs.flat['jsx-runtime'],
|
|
83
|
-
languageOptions: {
|
|
84
|
-
...reactPlugin.configs.flat.recommended.languageOptions,
|
|
85
|
-
globals: {
|
|
86
|
-
...globals.serviceworker,
|
|
87
|
-
...Object.keys(globals.browser).reduce<Record<string, boolean>>((acc, key) => {
|
|
88
|
-
acc[key.trim()] = globals.browser[key];
|
|
89
|
-
return acc;
|
|
90
|
-
}, {}),
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
plugins: {
|
|
94
|
-
'react-hooks': reactHooks,
|
|
95
|
-
},
|
|
96
|
-
rules: {
|
|
97
|
-
...reactHooks.configs.recommended.rules,
|
|
98
|
-
'react/react-in-jsx-scope': 'off',
|
|
99
|
-
'react/jsx-uses-react': 'off',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
files: ['**/*.test.{js,ts,jsx,tsx}'],
|
|
104
|
-
...jest.configs['flat/recommended'],
|
|
105
|
-
languageOptions: {
|
|
106
|
-
globals: {
|
|
107
|
-
...globals.jest,
|
|
108
|
-
//...globals.vitest,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
prettierRecommended,
|
|
113
|
-
{
|
|
114
|
-
ignores,
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
plugins: {
|
|
118
|
-
'unused-imports': unusedImports,
|
|
119
|
-
},
|
|
120
|
-
rules: {
|
|
121
|
-
'prettier/prettier': [
|
|
122
|
-
'error',
|
|
123
|
-
{
|
|
124
|
-
semi: true,
|
|
125
|
-
trailingComma: 'all',
|
|
126
|
-
singleQuote: true,
|
|
127
|
-
jsxSingleQuote: true,
|
|
128
|
-
printWidth: 120,
|
|
129
|
-
tabWidth: 2,
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
usePrettierrc: false,
|
|
133
|
-
fileInfoOptions: {
|
|
134
|
-
withNodeModules: true,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
'no-unused-vars': 'off',
|
|
139
|
-
'unused-imports/no-unused-imports': 'error',
|
|
140
|
-
'unused-imports/no-unused-vars': [
|
|
141
|
-
'error',
|
|
142
|
-
{
|
|
143
|
-
vars: 'all',
|
|
144
|
-
varsIgnorePattern: '^_',
|
|
145
|
-
args: 'after-used',
|
|
146
|
-
argsIgnorePattern: '^_',
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
'sort-imports': [
|
|
150
|
-
'error',
|
|
151
|
-
{
|
|
152
|
-
ignoreCase: true,
|
|
153
|
-
ignoreDeclarationSort: true,
|
|
154
|
-
ignoreMemberSort: false,
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
},
|
|
61
|
+
...reactHooksConfig,
|
|
62
|
+
...allConfig,
|
|
63
|
+
...unusedImportsConfig,
|
|
64
|
+
...sortImportsConfig,
|
|
65
|
+
...typescriptConfig,
|
|
66
|
+
...javascriptConfig,
|
|
67
|
+
...jestConfig,
|
|
68
|
+
...prettierConfig,
|
|
159
69
|
);
|
|
160
70
|
}
|
|
161
71
|
|
|
@@ -1,156 +1,44 @@
|
|
|
1
|
-
import js from '@eslint/js';
|
|
2
1
|
import type { TSESLint } from '@typescript-eslint/utils';
|
|
3
|
-
import imports from 'eslint-plugin-import';
|
|
4
|
-
import jest from 'eslint-plugin-jest';
|
|
5
|
-
import prettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
6
2
|
import reactPlugin from 'eslint-plugin-react';
|
|
7
|
-
import
|
|
8
|
-
import unusedImports from 'eslint-plugin-unused-imports';
|
|
9
|
-
import globalsImp from 'globals';
|
|
10
|
-
import { config, configs } from 'typescript-eslint';
|
|
3
|
+
import { config } from 'typescript-eslint';
|
|
11
4
|
|
|
5
|
+
import {
|
|
6
|
+
allConfig,
|
|
7
|
+
importsConfig,
|
|
8
|
+
javascriptConfig,
|
|
9
|
+
jestConfig,
|
|
10
|
+
prettierConfig,
|
|
11
|
+
reactHooksConfig,
|
|
12
|
+
sortImportsConfig,
|
|
13
|
+
typescriptConfig,
|
|
14
|
+
unusedImportsConfig,
|
|
15
|
+
} from '../commons/index.js';
|
|
12
16
|
import { EslintOptions } from '../types/index.js';
|
|
13
17
|
|
|
14
|
-
const globals = globalsImp as Record<string, Record<string, boolean>>;
|
|
15
|
-
|
|
16
18
|
function eslintReactConfig({ ignores }: EslintOptions): TSESLint.FlatConfig.ConfigArray {
|
|
17
19
|
return config(
|
|
18
|
-
js.configs.recommended,
|
|
19
|
-
imports.flatConfigs.recommended,
|
|
20
|
-
{
|
|
21
|
-
files: ['**/*.{js,jsx,mjs}'],
|
|
22
|
-
extends: [configs.base],
|
|
23
|
-
},
|
|
24
20
|
{
|
|
25
|
-
|
|
26
|
-
extends: [imports.flatConfigs.typescript, ...configs.recommended, ...configs.recommendedTypeChecked],
|
|
27
|
-
languageOptions: {
|
|
28
|
-
parserOptions: {
|
|
29
|
-
ecmaVersion: 'latest',
|
|
30
|
-
sourceType: 'module',
|
|
31
|
-
project: true,
|
|
32
|
-
tsconfigRootDir: './',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
rules: {
|
|
36
|
-
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
37
|
-
'@typescript-eslint/no-explicit-any': 'error',
|
|
38
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
39
|
-
},
|
|
21
|
+
ignores,
|
|
40
22
|
},
|
|
41
|
-
|
|
23
|
+
...allConfig,
|
|
24
|
+
...config({
|
|
42
25
|
files: ['**/*.{jsx,tsx}'],
|
|
43
26
|
...reactPlugin.configs.flat.recommended,
|
|
44
27
|
...reactPlugin.configs.flat['jsx-runtime'],
|
|
45
|
-
languageOptions: {
|
|
46
|
-
...reactPlugin.configs.flat.recommended.languageOptions,
|
|
47
|
-
globals: {
|
|
48
|
-
...globals.serviceworker,
|
|
49
|
-
...Object.keys(globals.browser).reduce<Record<string, boolean>>((acc, key) => {
|
|
50
|
-
acc[key.trim()] = globals.browser[key];
|
|
51
|
-
return acc;
|
|
52
|
-
}, {}),
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
plugins: {
|
|
56
|
-
'react-hooks': reactHooks,
|
|
57
|
-
},
|
|
58
|
-
rules: {
|
|
59
|
-
...reactHooks.configs.recommended.rules,
|
|
60
|
-
'react/react-in-jsx-scope': 'off',
|
|
61
|
-
'react/jsx-uses-react': 'off',
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
files: ['**/*.test.{js,ts,jsx,tsx}'],
|
|
66
|
-
...jest.configs['flat/recommended'],
|
|
67
|
-
languageOptions: {
|
|
68
|
-
globals: {
|
|
69
|
-
...globals.jest,
|
|
70
|
-
//...globals.vitest,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
prettierRecommended,
|
|
75
|
-
{
|
|
76
|
-
ignores,
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
plugins: {
|
|
80
|
-
'unused-imports': unusedImports,
|
|
81
|
-
},
|
|
82
|
-
rules: {
|
|
83
|
-
'prettier/prettier': [
|
|
84
|
-
'error',
|
|
85
|
-
{
|
|
86
|
-
semi: true,
|
|
87
|
-
trailingComma: 'all',
|
|
88
|
-
singleQuote: true,
|
|
89
|
-
jsxSingleQuote: true,
|
|
90
|
-
printWidth: 120,
|
|
91
|
-
tabWidth: 2,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
usePrettierrc: false,
|
|
95
|
-
fileInfoOptions: {
|
|
96
|
-
withNodeModules: true,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
'no-unused-vars': 'off',
|
|
101
|
-
'unused-imports/no-unused-imports': 'error',
|
|
102
|
-
'unused-imports/no-unused-vars': [
|
|
103
|
-
'error',
|
|
104
|
-
{
|
|
105
|
-
vars: 'all',
|
|
106
|
-
varsIgnorePattern: '^_',
|
|
107
|
-
args: 'after-used',
|
|
108
|
-
argsIgnorePattern: '^_',
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
'sort-imports': [
|
|
112
|
-
'error',
|
|
113
|
-
{
|
|
114
|
-
ignoreCase: true,
|
|
115
|
-
ignoreDeclarationSort: true,
|
|
116
|
-
ignoreMemberSort: false,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
'import/order': [
|
|
120
|
-
'error',
|
|
121
|
-
{
|
|
122
|
-
groups: ['builtin', 'external', 'internal', ['parent', 'sibling']],
|
|
123
|
-
pathGroups: [
|
|
124
|
-
{
|
|
125
|
-
pattern: 'react',
|
|
126
|
-
group: 'external',
|
|
127
|
-
position: 'before',
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
pattern: '@tarsilla/**',
|
|
131
|
-
group: 'internal',
|
|
132
|
-
position: 'before',
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
pathGroupsExcludedImportTypes: ['react', '@tarsilla'],
|
|
136
|
-
'newlines-between': 'always',
|
|
137
|
-
alphabetize: {
|
|
138
|
-
order: 'asc',
|
|
139
|
-
caseInsensitive: true,
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
28
|
settings: {
|
|
145
|
-
'import/resolver': {
|
|
146
|
-
typescript: true,
|
|
147
|
-
node: true,
|
|
148
|
-
},
|
|
149
29
|
react: {
|
|
150
30
|
version: 'detect',
|
|
151
31
|
},
|
|
152
32
|
},
|
|
153
|
-
},
|
|
33
|
+
}),
|
|
34
|
+
...reactHooksConfig,
|
|
35
|
+
...unusedImportsConfig,
|
|
36
|
+
...sortImportsConfig,
|
|
37
|
+
...importsConfig,
|
|
38
|
+
...typescriptConfig,
|
|
39
|
+
...javascriptConfig,
|
|
40
|
+
...jestConfig,
|
|
41
|
+
...prettierConfig,
|
|
154
42
|
);
|
|
155
43
|
}
|
|
156
44
|
|