@boehringer-ingelheim/eslint-config 9.3.0 → 9.5.0-typescript.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/package.json +32 -16
- package/configs/base.js +0 -145
- package/configs/experimental-naming-convention.js +0 -68
- package/configs/local.js +0 -16
- package/configs/nextjs.js +0 -137
- package/configs/playwright.js +0 -26
- package/configs/prettier-disable.js +0 -10
- package/configs/react.js +0 -110
- package/configs/strict.js +0 -22
- package/index.d.ts +0 -24
- package/index.js +0 -26
- package/lib/eslint-plugin-perfectionist.js +0 -87
- package/lib/include-ignore-file.js +0 -28
- package/lib/nextjs.utils.js +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boehringer-ingelheim/eslint-config",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.5.0-typescript.1",
|
|
4
4
|
"description": "Shared eslint configuration used at Boehringer Ingelheim for code styling",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"boehringer",
|
|
@@ -22,24 +22,36 @@
|
|
|
22
22
|
"url": "https://github.com/Boehringer-Ingelheim/eslint-config/issues"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"
|
|
26
|
-
"lib",
|
|
27
|
-
"index.js",
|
|
28
|
-
"index.d.ts"
|
|
25
|
+
"dist"
|
|
29
26
|
],
|
|
30
|
-
"main": "
|
|
31
|
-
"types": "
|
|
27
|
+
"main": "dist/main.js",
|
|
28
|
+
"types": "dist/main.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"default": "./dist/main.js",
|
|
32
|
+
"types": "./dist/main.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./configs/*": {
|
|
35
|
+
"default": "./dist/configs/*.js",
|
|
36
|
+
"types": "./dist/configs/*.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./lib/*": {
|
|
39
|
+
"default": "./dist/lib/*.js",
|
|
40
|
+
"types": "./dist/lib/*.d.ts"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
32
43
|
"scripts": {
|
|
33
44
|
"prepare": "husky",
|
|
34
45
|
"release": "semantic-release",
|
|
35
46
|
"repair": "npx --yes rimraf@6 .git/hooks node_modules package-lock.json && npm install",
|
|
36
|
-
"lint": "eslint ."
|
|
47
|
+
"lint": "eslint .",
|
|
48
|
+
"build": "tsc"
|
|
37
49
|
},
|
|
38
50
|
"peerDependencies": {
|
|
39
51
|
"eslint": ">= 9.34.0"
|
|
40
52
|
},
|
|
41
53
|
"dependencies": {
|
|
42
|
-
"@eslint/compat": "^2.0.
|
|
54
|
+
"@eslint/compat": "^2.0.1",
|
|
43
55
|
"@eslint/js": "^9.39.2",
|
|
44
56
|
"@next/eslint-plugin-next": "^16.1.1",
|
|
45
57
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -47,23 +59,27 @@
|
|
|
47
59
|
"eslint-plugin-import": "^2.32.0",
|
|
48
60
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
49
61
|
"eslint-plugin-perfectionist": "^5.3.1",
|
|
50
|
-
"eslint-plugin-playwright": "^2.
|
|
62
|
+
"eslint-plugin-playwright": "^2.5.0",
|
|
51
63
|
"eslint-plugin-react": "^7.37.5",
|
|
52
64
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
53
65
|
"eslint-plugin-react-refresh": "^0.4.26",
|
|
54
66
|
"eslint-plugin-sonarjs": "^3.0.5",
|
|
55
67
|
"globals": "^17.0.0",
|
|
56
68
|
"is-ci": "^4.1.0",
|
|
57
|
-
"typescript-eslint": "^8.
|
|
69
|
+
"typescript-eslint": "^8.53.0"
|
|
58
70
|
},
|
|
59
71
|
"devDependencies": {
|
|
60
72
|
"@boehringer-ingelheim/prettier-config": "2.0.0",
|
|
61
|
-
"@commitlint/cli": "20.3.
|
|
62
|
-
"@commitlint/config-conventional": "20.3.
|
|
63
|
-
"@commitlint/types": "20.
|
|
73
|
+
"@commitlint/cli": "20.3.1",
|
|
74
|
+
"@commitlint/config-conventional": "20.3.1",
|
|
75
|
+
"@commitlint/types": "20.3.1",
|
|
76
|
+
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
77
|
+
"@types/node": "^25.7.0",
|
|
64
78
|
"dotenv-cli": "11.0.0",
|
|
65
79
|
"husky": "9.1.7",
|
|
66
80
|
"prettier": "3.7.4",
|
|
67
|
-
"semantic-release": "25.0.2"
|
|
68
|
-
|
|
81
|
+
"semantic-release": "25.0.2",
|
|
82
|
+
"typescript": "^5.9.3"
|
|
83
|
+
},
|
|
84
|
+
"type": "module"
|
|
69
85
|
}
|
package/configs/base.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
const eslint = require('@eslint/js');
|
|
2
|
-
const importPlugin = require('eslint-plugin-import');
|
|
3
|
-
const perfectionist = require('eslint-plugin-perfectionist');
|
|
4
|
-
const sonarjs = require('eslint-plugin-sonarjs');
|
|
5
|
-
const { defineConfig } = require('eslint/config');
|
|
6
|
-
const tseslint = require('typescript-eslint');
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
PERFECTIONIST_SETTINGS,
|
|
10
|
-
SORT_CLASSES_GROUPS,
|
|
11
|
-
SORT_IMPORTS_GROUPS,
|
|
12
|
-
SORT_INTERSECTION_TYPES_GROUPS,
|
|
13
|
-
} = require('../lib/eslint-plugin-perfectionist.js');
|
|
14
|
-
|
|
15
|
-
module.exports = defineConfig(
|
|
16
|
-
eslint.configs.recommended,
|
|
17
|
-
tseslint.configs.recommendedTypeChecked,
|
|
18
|
-
tseslint.configs.stylisticTypeChecked,
|
|
19
|
-
importPlugin.flatConfigs.recommended,
|
|
20
|
-
importPlugin.flatConfigs.typescript,
|
|
21
|
-
perfectionist.configs['recommended-natural'],
|
|
22
|
-
sonarjs.configs.recommended,
|
|
23
|
-
{
|
|
24
|
-
languageOptions: {
|
|
25
|
-
parserOptions: {
|
|
26
|
-
// find the tsconfig.json nearest each source file
|
|
27
|
-
projectService: true,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
linterOptions: {
|
|
31
|
-
reportUnusedDisableDirectives: 'error',
|
|
32
|
-
},
|
|
33
|
-
rules: {
|
|
34
|
-
// @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
|
|
35
|
-
'@typescript-eslint/adjacent-overload-signatures': 'off', // disabled due to conflict with eslint-plugin-perfectionist
|
|
36
|
-
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
|
|
37
|
-
'@typescript-eslint/no-misused-promises': [
|
|
38
|
-
'error',
|
|
39
|
-
{
|
|
40
|
-
checksVoidReturn: false,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
'@typescript-eslint/no-unused-vars': [
|
|
44
|
-
'error',
|
|
45
|
-
{
|
|
46
|
-
argsIgnorePattern: '^_',
|
|
47
|
-
caughtErrorsIgnorePattern: '^_',
|
|
48
|
-
varsIgnorePattern: '^_',
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
'@typescript-eslint/sort-type-constituents': 'off', // disabled due to conflict with eslint-plugin-perfectionist
|
|
52
|
-
|
|
53
|
-
// eslint: https://github.com/eslint/eslint/tree/main/lib/rules
|
|
54
|
-
'@typescript-eslint/dot-notation': ['error', { allowPattern: '^[a-z]+(_[a-z]+)+$' }],
|
|
55
|
-
'arrow-body-style': ['error', 'as-needed'],
|
|
56
|
-
camelcase: 'warn',
|
|
57
|
-
curly: 'error',
|
|
58
|
-
'default-case': 'error',
|
|
59
|
-
eqeqeq: 'error',
|
|
60
|
-
'logical-assignment-operators': ['error', 'never'],
|
|
61
|
-
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
62
|
-
'no-else-return': ['error', { allowElseIf: false }],
|
|
63
|
-
'no-lonely-if': 'error',
|
|
64
|
-
'no-negated-condition': 'error',
|
|
65
|
-
'no-nested-ternary': 'error',
|
|
66
|
-
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
|
|
67
|
-
'no-unneeded-ternary': 'error',
|
|
68
|
-
'no-useless-concat': 'error',
|
|
69
|
-
'operator-assignment': ['error', 'never'],
|
|
70
|
-
'prefer-template': 'error',
|
|
71
|
-
'sort-imports': 'off', // disabled due to conflict with eslint-plugin-perfectionist
|
|
72
|
-
'sort-keys': 'off', // disabled due to conflict with eslint-plugin-perfectionist
|
|
73
|
-
|
|
74
|
-
// eslint-plugin-import: https://github.com/import-js/eslint-plugin-import/tree/main/docs/rules
|
|
75
|
-
'import/no-cycle': 'error',
|
|
76
|
-
/**
|
|
77
|
-
* The rule is disabled for now as it is not compatible with flat-configs, without adding an artifical `.eslintrc` file.
|
|
78
|
-
*
|
|
79
|
-
* @see: https://github.com/import-js/eslint-plugin-import/issues/3079#issuecomment-2557191925
|
|
80
|
-
* @todo Enable rule, as soon as fix is available: https://github.com/Boehringer-Ingelheim/eslint-config/blob/9f028ed43bb5db11082a2982f249ddfe7eaf5c13/configs/base.js#L77
|
|
81
|
-
*/
|
|
82
|
-
'import/no-unused-modules': 'off',
|
|
83
|
-
'import/order': 'off', // disabled due to conflict with eslint-plugin-perfectionist
|
|
84
|
-
'import/prefer-default-export': 'off',
|
|
85
|
-
|
|
86
|
-
// Deactivated as TypeScript provides the same checks as part of standard type checking: https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting
|
|
87
|
-
'import/default': 'off',
|
|
88
|
-
'import/named': 'off',
|
|
89
|
-
'import/namespace': 'off',
|
|
90
|
-
'import/no-named-as-default-member': 'off',
|
|
91
|
-
'import/no-unresolved': 'off',
|
|
92
|
-
|
|
93
|
-
// eslint-plugin-perfectionist: https://github.com/azat-io/eslint-plugin-perfectionist
|
|
94
|
-
'perfectionist/sort-classes': [
|
|
95
|
-
'error',
|
|
96
|
-
{
|
|
97
|
-
groups: SORT_CLASSES_GROUPS,
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
'perfectionist/sort-imports': [
|
|
101
|
-
'error',
|
|
102
|
-
{
|
|
103
|
-
groups: SORT_IMPORTS_GROUPS,
|
|
104
|
-
newlinesBetween: 0, // No newlines are allowed between groups
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
'perfectionist/sort-intersection-types': [
|
|
108
|
-
'error',
|
|
109
|
-
{
|
|
110
|
-
groups: SORT_INTERSECTION_TYPES_GROUPS,
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
'perfectionist/sort-named-imports': [
|
|
114
|
-
'error',
|
|
115
|
-
{
|
|
116
|
-
ignoreAlias: true,
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
'perfectionist/sort-objects': [
|
|
120
|
-
'error',
|
|
121
|
-
{
|
|
122
|
-
partitionByComment: true,
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
},
|
|
126
|
-
settings: {
|
|
127
|
-
'import/resolver': {
|
|
128
|
-
typescript: true,
|
|
129
|
-
},
|
|
130
|
-
perfectionist: {
|
|
131
|
-
...PERFECTIONIST_SETTINGS,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
files: [
|
|
137
|
-
'**/*.d.ts', // TypeScript declaration files
|
|
138
|
-
'**/*.{spec,test}.{js,cjs,mjs,jsx,ts,cts,mts,tsx}', // Usually test files
|
|
139
|
-
'./*.{js,cjs,mjs,ts,cts,mts}', // Mostly configuration files on root level
|
|
140
|
-
],
|
|
141
|
-
rules: {
|
|
142
|
-
'import/no-unused-modules': 'off',
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
);
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const { defineConfig } = require('eslint/config');
|
|
2
|
-
|
|
3
|
-
module.exports = defineConfig({
|
|
4
|
-
rules: {
|
|
5
|
-
'@typescript-eslint/naming-convention': [
|
|
6
|
-
'error',
|
|
7
|
-
{
|
|
8
|
-
// Enforce that interface names do not start with an 'I'
|
|
9
|
-
custom: {
|
|
10
|
-
match: false,
|
|
11
|
-
regex: '^I[A-Z]',
|
|
12
|
-
},
|
|
13
|
-
format: ['StrictPascalCase'],
|
|
14
|
-
leadingUnderscore: 'forbid',
|
|
15
|
-
selector: 'interface',
|
|
16
|
-
trailingUnderscore: 'forbid',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
// Enforce that type alias names do not start with an 'T'
|
|
20
|
-
custom: {
|
|
21
|
-
match: false,
|
|
22
|
-
regex: '^T[A-Z]',
|
|
23
|
-
},
|
|
24
|
-
format: ['StrictPascalCase'],
|
|
25
|
-
leadingUnderscore: 'forbid',
|
|
26
|
-
selector: 'typeAlias',
|
|
27
|
-
trailingUnderscore: 'forbid',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
// Enforce that all top-level variables are in UPPER_CASE
|
|
31
|
-
format: ['UPPER_CASE'],
|
|
32
|
-
leadingUnderscore: 'forbid',
|
|
33
|
-
modifiers: ['global'],
|
|
34
|
-
selector: 'variable',
|
|
35
|
-
trailingUnderscore: 'forbid',
|
|
36
|
-
types: ['boolean', 'number', 'string'],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
// Enforce that all top-level array variables are in UPPER_CASE and are suffixed with a 'S' to indicate plural form
|
|
40
|
-
format: ['UPPER_CASE'],
|
|
41
|
-
leadingUnderscore: 'forbid',
|
|
42
|
-
modifiers: ['global'],
|
|
43
|
-
selector: 'variable',
|
|
44
|
-
suffix: ['S'],
|
|
45
|
-
trailingUnderscore: 'forbid',
|
|
46
|
-
types: ['array'],
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
// Enforce that array variables are suffixed with a 's' to indicate plural form
|
|
50
|
-
format: ['strictCamelCase'],
|
|
51
|
-
leadingUnderscore: 'forbid',
|
|
52
|
-
selector: 'variable',
|
|
53
|
-
suffix: ['s'],
|
|
54
|
-
trailingUnderscore: 'forbid',
|
|
55
|
-
types: ['array'],
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
// Enforce that boolean variables are prefixed with an allowed verb
|
|
59
|
-
format: ['StrictPascalCase'],
|
|
60
|
-
leadingUnderscore: 'forbid',
|
|
61
|
-
prefix: ['is', 'has', 'should', 'can'],
|
|
62
|
-
selector: 'variable',
|
|
63
|
-
trailingUnderscore: 'forbid',
|
|
64
|
-
types: ['boolean'],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
});
|
package/configs/local.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const { defineConfig } = require('eslint/config');
|
|
2
|
-
const isCI = require('is-ci');
|
|
3
|
-
|
|
4
|
-
module.exports = defineConfig(
|
|
5
|
-
isCI
|
|
6
|
-
? {}
|
|
7
|
-
: {
|
|
8
|
-
rules: {
|
|
9
|
-
// Only activate in CI, as suggested here: https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting#eslint-plugin-import
|
|
10
|
-
'import/no-cycle': 'off',
|
|
11
|
-
'import/no-deprecated': 'off',
|
|
12
|
-
'import/no-named-as-default': 'off',
|
|
13
|
-
'import/no-unused-modules': 'off',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
);
|
package/configs/nextjs.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
const nextPlugin = require('@next/eslint-plugin-next');
|
|
2
|
-
const { defineConfig } = require('eslint/config');
|
|
3
|
-
|
|
4
|
-
const { NEXTJS_ROUTING_FILES } = require('../lib/nextjs.utils.js');
|
|
5
|
-
const react = require('./react.js');
|
|
6
|
-
|
|
7
|
-
module.exports = defineConfig(
|
|
8
|
-
...react,
|
|
9
|
-
{
|
|
10
|
-
plugins: {
|
|
11
|
-
'@next/next': nextPlugin,
|
|
12
|
-
},
|
|
13
|
-
rules: {
|
|
14
|
-
...nextPlugin.configs.recommended.rules,
|
|
15
|
-
...nextPlugin.configs['core-web-vitals'].rules,
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
files: [`{app,src/app}/**/{${NEXTJS_ROUTING_FILES.join(',')}}.{ts,tsx}`],
|
|
20
|
-
rules: {
|
|
21
|
-
'import/no-unused-modules': ['off'],
|
|
22
|
-
|
|
23
|
-
// eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
24
|
-
'react-refresh/only-export-components': [
|
|
25
|
-
'warn',
|
|
26
|
-
{
|
|
27
|
-
allowExportNames: [
|
|
28
|
-
/**
|
|
29
|
-
* Next.js allows exporting the following options in pages, layouts and route handlers
|
|
30
|
-
*
|
|
31
|
-
* @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
|
|
32
|
-
*/
|
|
33
|
-
'dynamic',
|
|
34
|
-
'dynamicParams',
|
|
35
|
-
'fetchCache',
|
|
36
|
-
'maxDuration',
|
|
37
|
-
'preferredRegion',
|
|
38
|
-
'revalidate',
|
|
39
|
-
'runtime',
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Next.js allows exporting the following metadata options in layouts and pages
|
|
43
|
-
*
|
|
44
|
-
* @link https://nextjs.org/docs/app/api-reference/functions/generate-metadata
|
|
45
|
-
*/
|
|
46
|
-
'generateMetadata',
|
|
47
|
-
'metadata',
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Next.js allows exporting the following static params functions in pages
|
|
51
|
-
*
|
|
52
|
-
* @link https://nextjs.org/docs/app/api-reference/functions/generate-static-params
|
|
53
|
-
*/
|
|
54
|
-
'generateStaticParams',
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Next.js allows exporting the following viewport options in layouts and pages
|
|
58
|
-
*
|
|
59
|
-
* @link https://nextjs.org/docs/app/api-reference/functions/generate-viewport
|
|
60
|
-
*/
|
|
61
|
-
'generateViewport',
|
|
62
|
-
'viewport',
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
files: [`{instrumentation,src/instrumentation}.{ts,tsx}`],
|
|
70
|
-
rules: {
|
|
71
|
-
'import/no-unused-modules': ['off'],
|
|
72
|
-
|
|
73
|
-
// eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
74
|
-
'react-refresh/only-export-components': [
|
|
75
|
-
'warn',
|
|
76
|
-
{
|
|
77
|
-
allowExportNames: [
|
|
78
|
-
/**
|
|
79
|
-
* Next.js allows exporting the following exports in instrumentation files
|
|
80
|
-
*
|
|
81
|
-
* @link https://nextjs.org/docs/app/guides/instrumentation#convention
|
|
82
|
-
*/
|
|
83
|
-
'register',
|
|
84
|
-
],
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
/**
|
|
91
|
-
* Next.js 'middleware' files are beeing deprecated in favor of the new proxy files with v16+
|
|
92
|
-
*
|
|
93
|
-
* @link https://nextjs.org/blog/next-16#proxyts-formerly-middlewarets
|
|
94
|
-
*/
|
|
95
|
-
files: [`{middleware,src/middleware}.{ts,tsx}`],
|
|
96
|
-
rules: {
|
|
97
|
-
'import/no-unused-modules': ['off'],
|
|
98
|
-
|
|
99
|
-
// eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
100
|
-
'react-refresh/only-export-components': [
|
|
101
|
-
'warn',
|
|
102
|
-
{
|
|
103
|
-
allowExportNames: [
|
|
104
|
-
/**
|
|
105
|
-
* Next.js allows exporting the following config options in middleware
|
|
106
|
-
*
|
|
107
|
-
* @link https://nextjs.org/docs/app/api-reference/file-conventions/middleware#config-object-optional
|
|
108
|
-
*/
|
|
109
|
-
'config',
|
|
110
|
-
],
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
files: [`{proxy,src/proxy}.{ts,tsx}`],
|
|
117
|
-
rules: {
|
|
118
|
-
'import/no-unused-modules': ['off'],
|
|
119
|
-
|
|
120
|
-
// eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
121
|
-
'react-refresh/only-export-components': [
|
|
122
|
-
'warn',
|
|
123
|
-
{
|
|
124
|
-
allowExportNames: [
|
|
125
|
-
/**
|
|
126
|
-
* Next.js allows exporting the following exports in proxy files
|
|
127
|
-
*
|
|
128
|
-
* @link https://nextjs.org/docs/app/api-reference/file-conventions/proxy#config-object-optional
|
|
129
|
-
*/
|
|
130
|
-
'config',
|
|
131
|
-
'proxy',
|
|
132
|
-
],
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
);
|
package/configs/playwright.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const playwright = require('eslint-plugin-playwright');
|
|
2
|
-
const { defineConfig } = require('eslint/config');
|
|
3
|
-
|
|
4
|
-
module.exports = defineConfig({
|
|
5
|
-
...playwright.configs['flat/recommended'],
|
|
6
|
-
rules: {
|
|
7
|
-
/**
|
|
8
|
-
* At the moment, `eslint-plugin-playwright` does not fully support component testing with type information.
|
|
9
|
-
* https://github.com/playwright-community/eslint-plugin-playwright/issues/298
|
|
10
|
-
*
|
|
11
|
-
* The `mount` function is flagged as an error by the `@typescript-eslint/unbound-method` rule.
|
|
12
|
-
* But it is okay to use `mount` in this context for test files.
|
|
13
|
-
* https://typescript-eslint.io/rules/unbound-method/#when-not-to-use-it
|
|
14
|
-
*
|
|
15
|
-
* Hint: `eslint-plugin-jest` has already a customized version of this rule.
|
|
16
|
-
* https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md
|
|
17
|
-
*/
|
|
18
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
19
|
-
|
|
20
|
-
// eslint-plugin-playwright: https://github.com/playwright-community/eslint-plugin-playwright
|
|
21
|
-
...playwright.configs['flat/recommended'].rules,
|
|
22
|
-
'playwright/prefer-to-be': 'error',
|
|
23
|
-
'playwright/prefer-to-have-length': 'error',
|
|
24
|
-
'playwright/require-top-level-describe': 'error',
|
|
25
|
-
},
|
|
26
|
-
});
|
package/configs/react.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
const jsxA11y = require('eslint-plugin-jsx-a11y');
|
|
2
|
-
const react = require('eslint-plugin-react');
|
|
3
|
-
const reactHooks = require('eslint-plugin-react-hooks');
|
|
4
|
-
const reactRefresh = require('eslint-plugin-react-refresh');
|
|
5
|
-
const { defineConfig } = require('eslint/config');
|
|
6
|
-
const globals = require('globals');
|
|
7
|
-
const { PERFECTIONIST_SETTINGS, SORT_IMPORTS_GROUPS } = require('../lib/eslint-plugin-perfectionist.js');
|
|
8
|
-
const base = require('./base.js');
|
|
9
|
-
|
|
10
|
-
module.exports = defineConfig(
|
|
11
|
-
...base,
|
|
12
|
-
jsxA11y.flatConfigs.recommended,
|
|
13
|
-
react.configs.flat.recommended,
|
|
14
|
-
react.configs.flat['jsx-runtime'],
|
|
15
|
-
reactRefresh.configs.recommended,
|
|
16
|
-
{
|
|
17
|
-
languageOptions: {
|
|
18
|
-
globals: {
|
|
19
|
-
...globals.browser,
|
|
20
|
-
},
|
|
21
|
-
parserOptions: {
|
|
22
|
-
ecmaFeatures: {
|
|
23
|
-
jsx: true,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
plugins: {
|
|
28
|
-
'react-hooks': reactHooks,
|
|
29
|
-
},
|
|
30
|
-
rules: {
|
|
31
|
-
// @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
|
|
32
|
-
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
|
|
33
|
-
'@typescript-eslint/no-restricted-types': [
|
|
34
|
-
'error',
|
|
35
|
-
{
|
|
36
|
-
types: {
|
|
37
|
-
'React.FC': {
|
|
38
|
-
message:
|
|
39
|
-
'Please use object type destructure declaration, see: https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components',
|
|
40
|
-
},
|
|
41
|
-
'React.FunctionalComponent': {
|
|
42
|
-
message:
|
|
43
|
-
'Please use object type destructure declaration, see: https://react-typescript-cheatsheet.netlify.app/docs/basic/getting-started/function_components',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
|
|
49
|
-
// eslint-plugin-react: https://github.com/jsx-eslint/eslint-plugin-react/tree/master/lib/rules
|
|
50
|
-
'react/jsx-pascal-case': 'error',
|
|
51
|
-
'react/jsx-sort-props': 'off', // disabled due to conflict with eslint-plugin-perfectionist
|
|
52
|
-
'react/sort-default-props': 'error',
|
|
53
|
-
|
|
54
|
-
// eslint-plugin-react-hooks: https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md
|
|
55
|
-
'react-hooks/exhaustive-deps': 'error',
|
|
56
|
-
'react-hooks/rules-of-hooks': 'error',
|
|
57
|
-
|
|
58
|
-
// eslint-plugin-perfectionist: https://github.com/azat-io/eslint-plugin-perfectionist
|
|
59
|
-
'perfectionist/sort-imports': [
|
|
60
|
-
'error',
|
|
61
|
-
{
|
|
62
|
-
customGroups: [
|
|
63
|
-
{
|
|
64
|
-
elementNamePattern: ['^react$'],
|
|
65
|
-
groupName: 'react',
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
groups: ['react', ...SORT_IMPORTS_GROUPS],
|
|
69
|
-
newlinesBetween: 0, // No newlines are allowed between groups
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
'perfectionist/sort-jsx-props': [
|
|
73
|
-
'error',
|
|
74
|
-
{
|
|
75
|
-
customGroups: [
|
|
76
|
-
{
|
|
77
|
-
elementNamePattern: '^on.+',
|
|
78
|
-
groupName: 'callback',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
elementNamePattern: ['children', 'dangerouslySetInnerHTML', 'key', 'ref'], // Reserved props from: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/lib/rules/jsx-sort-props.js#L41-L46
|
|
82
|
-
groupName: 'reservedProps',
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
groups: ['reservedProps', 'unknown', 'callback'],
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
|
|
89
|
-
// eslint-plugin-react-refresh: https://github.com/ArnaudBarre/eslint-plugin-react-refresh
|
|
90
|
-
'react-refresh/only-export-components': 'warn',
|
|
91
|
-
|
|
92
|
-
// Forbid enum declaration
|
|
93
|
-
'no-restricted-syntax': [
|
|
94
|
-
'error',
|
|
95
|
-
{
|
|
96
|
-
message: "Don't declare enums",
|
|
97
|
-
selector: 'TSEnumDeclaration',
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
settings: {
|
|
102
|
-
perfectionist: {
|
|
103
|
-
...PERFECTIONIST_SETTINGS,
|
|
104
|
-
},
|
|
105
|
-
react: {
|
|
106
|
-
version: 'detect',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
);
|
package/configs/strict.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const { defineConfig } = require('eslint/config');
|
|
2
|
-
const tseslint = require('typescript-eslint');
|
|
3
|
-
|
|
4
|
-
const base = require('./base.js');
|
|
5
|
-
|
|
6
|
-
module.exports = defineConfig(...base, tseslint.configs.strictTypeChecked, {
|
|
7
|
-
rules: {
|
|
8
|
-
// @typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin/docs/rules
|
|
9
|
-
'@typescript-eslint/consistent-type-imports': 'error',
|
|
10
|
-
'@typescript-eslint/no-import-type-side-effects': 'error',
|
|
11
|
-
'@typescript-eslint/restrict-template-expressions': [
|
|
12
|
-
'error',
|
|
13
|
-
{
|
|
14
|
-
...tseslint.plugin.rules['restrict-template-expressions'].meta.docs.recommended.strict[0],
|
|
15
|
-
allowNumber: true,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
|
|
19
|
-
// eslint-plugin-import: https://github.com/import-js/eslint-plugin-import/tree/main/docs/rules
|
|
20
|
-
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
|
|
21
|
-
},
|
|
22
|
-
});
|
package/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Linter } from 'eslint';
|
|
2
|
-
|
|
3
|
-
type Configs =
|
|
4
|
-
| 'base'
|
|
5
|
-
| 'experimentalNamingConvention'
|
|
6
|
-
| 'local'
|
|
7
|
-
| 'nextjs'
|
|
8
|
-
| 'playwright'
|
|
9
|
-
| 'prettierDisable'
|
|
10
|
-
| 'react'
|
|
11
|
-
| 'strict';
|
|
12
|
-
|
|
13
|
-
declare module './index.js' {
|
|
14
|
-
export const configs: Record<Configs, Linter.Config[]>;
|
|
15
|
-
/**
|
|
16
|
-
* Reads an ignore file (e.g. `.gitignore`) and returns an object with the ignore patterns.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} [ignoreFilePath='.gitignore'] - The path to the ignore file. Defaults to `.gitignore`.
|
|
19
|
-
* @throws {TypeError} If the provided path is not a string.
|
|
20
|
-
* @throws {Error} If the provided path is an empty string.
|
|
21
|
-
* @returns {Linter.Config} The result of including the ignore file at the resolved absolute path.
|
|
22
|
-
*/
|
|
23
|
-
export const includeIgnoreFile: (ignoreFilePath?: string) => Linter.Config;
|
|
24
|
-
}
|
package/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const tseslint = require('typescript-eslint');
|
|
2
|
-
|
|
3
|
-
const base = require('./configs/base.js');
|
|
4
|
-
const experimentalNamingConvention = require('./configs/experimental-naming-convention.js');
|
|
5
|
-
const local = require('./configs/local.js');
|
|
6
|
-
const nextjs = require('./configs/nextjs.js');
|
|
7
|
-
const playwright = require('./configs/playwright.js');
|
|
8
|
-
const prettierDisable = require('./configs/prettier-disable.js');
|
|
9
|
-
const react = require('./configs/react.js');
|
|
10
|
-
const strict = require('./configs/strict.js');
|
|
11
|
-
const { includeIgnoreFile } = require('./lib/include-ignore-file.js');
|
|
12
|
-
|
|
13
|
-
module.exports = {
|
|
14
|
-
config: tseslint.config,
|
|
15
|
-
configs: {
|
|
16
|
-
base,
|
|
17
|
-
experimentalNamingConvention,
|
|
18
|
-
local,
|
|
19
|
-
nextjs,
|
|
20
|
-
playwright,
|
|
21
|
-
prettierDisable,
|
|
22
|
-
react,
|
|
23
|
-
strict,
|
|
24
|
-
},
|
|
25
|
-
includeIgnoreFile,
|
|
26
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Opinionated 'default' settings for eslint-plugin-perfectionist.
|
|
3
|
-
* @see https://perfectionist.dev/guide/getting-started#settings
|
|
4
|
-
*/
|
|
5
|
-
const PERFECTIONIST_SETTINGS = {
|
|
6
|
-
ignoreCase: true, // Ignore case when sorting
|
|
7
|
-
type: 'natural',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* While the sorting of imports is done by `eslint-plugin-perfectionist/sort-imports`,
|
|
12
|
-
* the order and grouping of imports is still taken from the previous configuration of `eslint-plugin-import/order`,
|
|
13
|
-
* as it feels more natural.
|
|
14
|
-
* The following group names are available for configuration: https://eslint-plugin-perfectionist.azat.io/rules/sort-imports#groups
|
|
15
|
-
*/
|
|
16
|
-
const SORT_IMPORTS_GROUPS = [
|
|
17
|
-
['value-builtin', 'named-type-builtin'],
|
|
18
|
-
['value-external', 'named-type-external'],
|
|
19
|
-
['value-internal', 'named-type-internal'],
|
|
20
|
-
['value-parent', 'named-type-parent'],
|
|
21
|
-
['value-sibling', 'named-type-sibling'],
|
|
22
|
-
['value-index', 'named-type-index'],
|
|
23
|
-
'value-style',
|
|
24
|
-
['value-side-effect-style', 'value-side-effect'],
|
|
25
|
-
'value-ts-equals-import',
|
|
26
|
-
'unknown',
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* This is the the default groups configuration of all the recommended configs by eslint-plugin-perfectionist.
|
|
31
|
-
* This array can be used to reconfigure some options of the perfectionist/sort-classes rule without
|
|
32
|
-
* overwriting the groups configuration of this rule.
|
|
33
|
-
* This config can be found here:
|
|
34
|
-
* - https://eslint-plugin-perfectionist.azat.io/rules/sort-classes#groups
|
|
35
|
-
* - https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/index.ts#L61
|
|
36
|
-
*/
|
|
37
|
-
const SORT_CLASSES_GROUPS = [
|
|
38
|
-
'index-signature',
|
|
39
|
-
['static-property', 'static-accessor-property'],
|
|
40
|
-
['static-get-method', 'static-set-method'],
|
|
41
|
-
['protected-static-property', 'protected-static-accessor-property'],
|
|
42
|
-
['protected-static-get-method', 'protected-static-set-method'],
|
|
43
|
-
['private-static-property', 'private-static-accessor-property'],
|
|
44
|
-
['private-static-get-method', 'private-static-set-method'],
|
|
45
|
-
'static-block',
|
|
46
|
-
['property', 'accessor-property'],
|
|
47
|
-
['get-method', 'set-method'],
|
|
48
|
-
['protected-property', 'protected-accessor-property'],
|
|
49
|
-
['protected-get-method', 'protected-set-method'],
|
|
50
|
-
['private-property', 'private-accessor-property'],
|
|
51
|
-
['private-get-method', 'private-set-method'],
|
|
52
|
-
'constructor',
|
|
53
|
-
['static-method', 'static-function-property'],
|
|
54
|
-
['protected-static-method', 'protected-static-function-property'],
|
|
55
|
-
['private-static-method', 'private-static-function-property'],
|
|
56
|
-
['method', 'function-property'],
|
|
57
|
-
['protected-method', 'protected-function-property'],
|
|
58
|
-
['private-method', 'private-function-property'],
|
|
59
|
-
'unknown',
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Customized configuration to configure the perfectionist/sort-intersection-types rule.
|
|
64
|
-
* The following group names are available for configuration: https://perfectionist.dev/rules/sort-intersection-types#groups
|
|
65
|
-
*/
|
|
66
|
-
const SORT_INTERSECTION_TYPES_GROUPS = [
|
|
67
|
-
'conditional',
|
|
68
|
-
'function',
|
|
69
|
-
'import',
|
|
70
|
-
'intersection',
|
|
71
|
-
'union',
|
|
72
|
-
'named',
|
|
73
|
-
'keyword',
|
|
74
|
-
'literal',
|
|
75
|
-
'operator',
|
|
76
|
-
'tuple',
|
|
77
|
-
'object',
|
|
78
|
-
'nullish',
|
|
79
|
-
'unknown',
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
module.exports = {
|
|
83
|
-
PERFECTIONIST_SETTINGS,
|
|
84
|
-
SORT_CLASSES_GROUPS,
|
|
85
|
-
SORT_IMPORTS_GROUPS,
|
|
86
|
-
SORT_INTERSECTION_TYPES_GROUPS,
|
|
87
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { includeIgnoreFile: includeIgnoreFileAbsolute } = require('@eslint/compat');
|
|
2
|
-
const path = require('node:path');
|
|
3
|
-
const { cwd } = require('node:process');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Reads an ignore file (e.g. `.gitignore`) and returns an object with the ignore patterns.
|
|
7
|
-
*
|
|
8
|
-
* @param {string} [ignoreFilePath='.gitignore'] - The path to the ignore file. Defaults to `.gitignore`.
|
|
9
|
-
* @throws {TypeError} If the provided path is not a string.
|
|
10
|
-
* @throws {Error} If the provided path is an empty string.
|
|
11
|
-
* @returns {import('@eslint/compat').FlatConfig} The result of including the ignore file at the resolved absolute path.
|
|
12
|
-
*/
|
|
13
|
-
const includeIgnoreFile = (ignoreFilePath = '.gitignore') => {
|
|
14
|
-
if (typeof ignoreFilePath !== 'string') {
|
|
15
|
-
throw new TypeError('Expected a string');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (ignoreFilePath === '') {
|
|
19
|
-
throw new Error('Expected a non-empty string');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const absolutePath = path.resolve(cwd(), ignoreFilePath);
|
|
23
|
-
return includeIgnoreFileAbsolute(absolutePath);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
module.exports = {
|
|
27
|
-
includeIgnoreFile,
|
|
28
|
-
};
|
package/lib/nextjs.utils.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List of special file names used by Next.js for routing and layouts.
|
|
3
|
-
*
|
|
4
|
-
* These filenames have specific purposes in the Next.js app directory structure,
|
|
5
|
-
* such as defining pages, layouts, error boundaries, and loading states.
|
|
6
|
-
*
|
|
7
|
-
* @type {string[]}
|
|
8
|
-
* @see {@link https://nextjs.org/docs/app/getting-started/project-structure#routing-files}
|
|
9
|
-
*/
|
|
10
|
-
const NEXTJS_ROUTING_FILES = [
|
|
11
|
-
'default',
|
|
12
|
-
'error',
|
|
13
|
-
'global-error',
|
|
14
|
-
'layout',
|
|
15
|
-
'loading',
|
|
16
|
-
'not-found',
|
|
17
|
-
'page',
|
|
18
|
-
'route',
|
|
19
|
-
'template',
|
|
20
|
-
];
|
|
21
|
-
|
|
22
|
-
module.exports = {
|
|
23
|
-
NEXTJS_ROUTING_FILES,
|
|
24
|
-
};
|