@ringieraxelspringer/eslint-config 24.1.1 → 25.0.0-alpha.5
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/CHANGELOG.md +8 -0
- package/README.md +22 -35
- package/eslint.config.js +3 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +242 -142
- package/lib/index.js.map +1 -0
- package/package.json +21 -11
- package/src/declarations.d.ts +2 -0
- package/src/index.ts +243 -0
- package/tsconfig.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [25.0.0] - 2025-01-28
|
|
6
|
+
### Added
|
|
7
|
+
- [@gwozniak]: Eslint V9.
|
|
8
|
+
|
|
9
|
+
## [24.1.2] - 2025-01-03
|
|
10
|
+
### Removed
|
|
11
|
+
- [@mdulawa]: Disabled `react/react-in-jsx-scope` rule of `eslint-plugin-react`.
|
|
12
|
+
|
|
5
13
|
## [24.1.1] - 2024-11-14
|
|
6
14
|
### Added
|
|
7
15
|
- [@gheprovider]: GitHub Actions.
|
package/README.md
CHANGED
|
@@ -2,47 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
Common Ringier Axel Springer ESLint configuration.
|
|
4
4
|
|
|
5
|
-
## Requirements
|
|
6
|
-
|
|
7
|
-
### TypeScript
|
|
8
|
-
|
|
9
|
-
This package contains rules that require **TypeScript 3.9 or newer**.
|
|
10
|
-
If you use earlier version of TypeScript, you will have to use older version of this package (<7.0.0).
|
|
11
|
-
|
|
12
5
|
## Installation
|
|
13
6
|
|
|
14
7
|
```shell
|
|
15
8
|
npm install --save-dev @ringieraxelspringer/eslint-config
|
|
16
9
|
```
|
|
17
10
|
|
|
18
|
-
## Usage (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
## Usage (eslint.config.js)
|
|
12
|
+
|
|
13
|
+
### JavaScript/TypeScript
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
const rasEslintConfig = require('@ringieraxelspringer/eslint-config');
|
|
17
|
+
|
|
18
|
+
module.exports = rasEslintConfig.config();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### React
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const rasEslintConfig = require('@ringieraxelspringer/eslint-config');
|
|
25
|
+
|
|
26
|
+
module.exports = rasEslintConfig.config({ useReact: true });
|
|
33
27
|
```
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"@babel/eslint-parser": "^7.0.0"
|
|
42
|
-
},
|
|
43
|
-
"eslintConfig": {
|
|
44
|
-
"extends": "@ringieraxelspringer/eslint-config",
|
|
45
|
-
"parser": "@babel/eslint-parser"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
29
|
+
### Use Babel parser
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const rasEslintConfig = require('@ringieraxelspringer/eslint-config');
|
|
33
|
+
|
|
34
|
+
module.exports = rasEslintConfig.config({ jsParser: 'babel' });
|
|
48
35
|
```
|
package/eslint.config.js
ADDED
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
declare enum ConfigParamsJsParser {
|
|
3
|
+
DEFAULT = "default",
|
|
4
|
+
BABEL = "babel"
|
|
5
|
+
}
|
|
6
|
+
interface ConfigParams {
|
|
7
|
+
jsParser?: ConfigParamsJsParser;
|
|
8
|
+
useReact?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function config(params?: ConfigParams): Linter.Config[];
|
|
11
|
+
export {};
|
package/lib/index.js
CHANGED
|
@@ -1,132 +1,169 @@
|
|
|
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
|
-
'no-extra-semi': 'error',
|
|
62
|
-
'no-implicit-coercion': ['error', { boolean: true, disallowTemplateShorthand: true, number: true, string: true }],
|
|
63
|
-
'no-lonely-if': 'error',
|
|
64
|
-
'no-loop-func': 'error',
|
|
65
|
-
'no-magic-numbers': 'off',
|
|
66
|
-
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
67
|
-
'no-multi-spaces': 'error',
|
|
68
|
-
'no-process-exit': 'off',
|
|
69
|
-
'no-trailing-spaces': 'error',
|
|
70
|
-
'no-unused-vars': 'error',
|
|
71
|
-
'no-var': 'error',
|
|
72
|
-
'object-curly-spacing': ['error', 'always'],
|
|
73
|
-
'object-shorthand': ['error', 'properties'],
|
|
74
|
-
'operator-linebreak': ['error', 'before'],
|
|
75
|
-
'padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }, { allowSingleLineBlocks: false }],
|
|
76
|
-
'padding-line-between-statements': [
|
|
77
|
-
'error',
|
|
78
|
-
{ blankLine: 'always', prev: ['block', 'block-like', 'class', 'directive'], next: '*' },
|
|
79
|
-
{ blankLine: 'always', prev: '*', next: ['block', 'block-like', 'class', 'return'] },
|
|
80
|
-
{ blankLine: 'never', prev: 'case', next: ['case', 'default'] }
|
|
81
|
-
],
|
|
82
|
-
'prefer-arrow-callback': 'error',
|
|
83
|
-
'prefer-const': 'error',
|
|
84
|
-
'prefer-promise-reject-errors': 'off',
|
|
85
|
-
'prefer-template': 'error',
|
|
86
|
-
'quote-props': ['error', 'consistent-as-needed'],
|
|
87
|
-
'quotes': ['error', 'single'],
|
|
88
|
-
'require-atomic-updates': 'error',
|
|
89
|
-
'require-await': 'error',
|
|
90
|
-
'semi': ['error', 'always'],
|
|
91
|
-
'semi-spacing': ['error', { after: true, before: false }],
|
|
92
|
-
'space-before-blocks': 'error',
|
|
93
|
-
'space-before-function-paren': ['error', { anonymous: 'never', asyncArrow: 'always', named: 'never' }],
|
|
94
|
-
'space-infix-ops': 'error',
|
|
95
|
-
'space-in-parens': ['error', 'never'],
|
|
96
|
-
'yoda': 'error',
|
|
97
|
-
|
|
98
|
-
'import/newline-after-import': ['error', { count: 1 }],
|
|
99
|
-
'import/no-extraneous-dependencies': 'error',
|
|
100
|
-
|
|
101
|
-
'n/global-require': 'error',
|
|
102
|
-
'n/no-missing-import': 'off',
|
|
103
|
-
'n/no-unpublished-import': 'off',
|
|
104
|
-
'n/no-unpublished-require': 'off',
|
|
105
|
-
'n/prefer-global/buffer': 'error',
|
|
106
|
-
'n/no-process-exit': 'off',
|
|
107
|
-
|
|
108
|
-
'react/jsx-boolean-value': ['error', 'always'],
|
|
109
|
-
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
|
|
110
|
-
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: false }],
|
|
111
|
-
'react/jsx-max-props-per-line': ['error', { maximum: 3 }],
|
|
112
|
-
'react/jsx-tag-spacing': ['error', { beforeSelfClosing: 'always' }],
|
|
113
|
-
'react/self-closing-comp': 'error',
|
|
114
|
-
'react/sort-comp': 'error'
|
|
115
|
-
},
|
|
116
|
-
overrides: [
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.config = config;
|
|
40
|
+
const js_1 = __importDefault(require("@eslint/js"));
|
|
41
|
+
const eslint_plugin_n_1 = __importDefault(require("eslint-plugin-n"));
|
|
42
|
+
const eslint_plugin_react_1 = __importDefault(require("eslint-plugin-react"));
|
|
43
|
+
const eslint_parser_1 = __importDefault(require("@babel/eslint-parser"));
|
|
44
|
+
const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
|
|
45
|
+
const eslintPluginImport = __importStar(require("eslint-plugin-import"));
|
|
46
|
+
const eslint_plugin_react_hooks_1 = __importDefault(require("eslint-plugin-react-hooks"));
|
|
47
|
+
const eslint_plugin_js_1 = __importDefault(require("@stylistic/eslint-plugin-js"));
|
|
48
|
+
const eslint_plugin_ts_1 = __importDefault(require("@stylistic/eslint-plugin-ts"));
|
|
49
|
+
const eslint_plugin_jsx_1 = __importDefault(require("@stylistic/eslint-plugin-jsx"));
|
|
50
|
+
const globals_1 = __importDefault(require("globals"));
|
|
51
|
+
var ConfigParamsJsParser;
|
|
52
|
+
(function (ConfigParamsJsParser) {
|
|
53
|
+
ConfigParamsJsParser["DEFAULT"] = "default";
|
|
54
|
+
ConfigParamsJsParser["BABEL"] = "babel";
|
|
55
|
+
})(ConfigParamsJsParser || (ConfigParamsJsParser = {}));
|
|
56
|
+
function config(params = {}) {
|
|
57
|
+
var _a;
|
|
58
|
+
const configRules = [
|
|
59
|
+
js_1.default.configs.recommended,
|
|
60
|
+
...typescript_eslint_1.default.configs.recommended,
|
|
117
61
|
{
|
|
118
|
-
files: ['
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
],
|
|
123
|
-
plugins: [
|
|
124
|
-
'@typescript-eslint'
|
|
125
|
-
],
|
|
62
|
+
files: ['**/*.{cjs,js,jsx,mjs}'],
|
|
63
|
+
plugins: {
|
|
64
|
+
'@stylistic/js': eslint_plugin_js_1.default
|
|
65
|
+
},
|
|
126
66
|
rules: {
|
|
127
|
-
'@
|
|
128
|
-
'@
|
|
129
|
-
'
|
|
67
|
+
'@stylistic/js/semi': ['error', 'always'],
|
|
68
|
+
'@stylistic/js/space-infix-ops': 'error',
|
|
69
|
+
'camelcase': ['error', { ignoreDestructuring: true, properties: 'never' }]
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
files: ['**/*.{cjs,js,jsx,mjs,ts,tsx}'],
|
|
74
|
+
plugins: {
|
|
75
|
+
'import': eslintPluginImport,
|
|
76
|
+
'@stylistic/js': eslint_plugin_js_1.default
|
|
77
|
+
},
|
|
78
|
+
languageOptions: {
|
|
79
|
+
ecmaVersion: 2025,
|
|
80
|
+
sourceType: 'module',
|
|
81
|
+
globals: {
|
|
82
|
+
...globals_1.default.browser,
|
|
83
|
+
...globals_1.default.jest,
|
|
84
|
+
...globals_1.default.node,
|
|
85
|
+
...globals_1.default.es2025
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
rules: {
|
|
89
|
+
'@stylistic/js/array-bracket-newline': ['error', 'consistent'],
|
|
90
|
+
'@stylistic/js/array-element-newline': ['error', 'consistent'],
|
|
91
|
+
'@stylistic/js/arrow-spacing': 'error',
|
|
92
|
+
'@stylistic/js/brace-style': 'error',
|
|
93
|
+
'@stylistic/js/comma-dangle': ['error', 'never'],
|
|
94
|
+
'@stylistic/js/comma-spacing': ['error', { before: false, after: true }],
|
|
95
|
+
'@stylistic/js/dot-location': ['error', 'property'],
|
|
96
|
+
'@stylistic/js/eol-last': ['error', 'always'],
|
|
97
|
+
'@stylistic/js/func-call-spacing': ['error', 'never'],
|
|
98
|
+
'@stylistic/js/generator-star-spacing': ['error', { before: false, after: true }],
|
|
99
|
+
'@stylistic/js/indent': [
|
|
100
|
+
'error',
|
|
101
|
+
4,
|
|
102
|
+
{ CallExpression: { arguments: 'off' }, flatTernaryExpressions: false, SwitchCase: 1, VariableDeclarator: 1 }
|
|
103
|
+
],
|
|
104
|
+
'@stylistic/js/jsx-quotes': ['error', 'prefer-double'],
|
|
105
|
+
'@stylistic/js/key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
|
106
|
+
'@stylistic/js/keyword-spacing': ['error', { before: true }],
|
|
107
|
+
'@stylistic/js/lines-between-class-members': ['error', 'always'],
|
|
108
|
+
'@stylistic/js/linebreak-style': ['error', 'unix'],
|
|
109
|
+
'@stylistic/js/max-len': ['error', { code: 160, comments: 160, ignoreRegExpLiterals: true, ignoreTemplateLiterals: true, ignoreUrls: true }],
|
|
110
|
+
'@stylistic/js/max-statements-per-line': ['error', { max: 1 }],
|
|
111
|
+
'@stylistic/js/multiline-ternary': ['error', 'always-multiline'],
|
|
112
|
+
'@stylistic/js/no-extra-semi': 'error',
|
|
113
|
+
'@stylistic/js/no-multi-spaces': 'error',
|
|
114
|
+
'@stylistic/js/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
115
|
+
'@stylistic/js/no-trailing-spaces': 'error',
|
|
116
|
+
'@stylistic/js/object-curly-spacing': ['error', 'always'],
|
|
117
|
+
'@stylistic/js/operator-linebreak': ['error', 'before'],
|
|
118
|
+
'@stylistic/js/padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }, { allowSingleLineBlocks: false }],
|
|
119
|
+
'@stylistic/js/padding-line-between-statements': [
|
|
120
|
+
'error',
|
|
121
|
+
{ blankLine: 'always', prev: ['block', 'block-like', 'class', 'directive'], next: '*' },
|
|
122
|
+
{ blankLine: 'always', prev: '*', next: ['block', 'block-like', 'class', 'return'] },
|
|
123
|
+
{ blankLine: 'never', prev: 'case', next: ['case', 'default'] }
|
|
124
|
+
],
|
|
125
|
+
'@stylistic/js/quote-props': ['error', 'consistent-as-needed'],
|
|
126
|
+
'@stylistic/js/quotes': ['error', 'single'],
|
|
127
|
+
'@stylistic/js/semi-spacing': ['error', { after: true, before: false }],
|
|
128
|
+
'@stylistic/js/space-before-blocks': 'error',
|
|
129
|
+
'@stylistic/js/space-before-function-paren': ['error', { anonymous: 'never', asyncArrow: 'always', named: 'never' }],
|
|
130
|
+
'@stylistic/js/space-in-parens': ['error', 'never'],
|
|
131
|
+
'camelcase': ['error', { ignoreDestructuring: true, properties: 'never' }],
|
|
132
|
+
'curly': 'error',
|
|
133
|
+
'dot-notation': 'error',
|
|
134
|
+
'eqeqeq': ['error', 'always'],
|
|
135
|
+
'max-classes-per-file': ['warn', { ignoreExpressions: true, max: 1 }],
|
|
136
|
+
'no-alert': 'error',
|
|
137
|
+
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
|
|
138
|
+
'no-duplicate-imports': 'error',
|
|
139
|
+
'no-empty': 'error',
|
|
140
|
+
'no-empty-function': 'error',
|
|
141
|
+
'no-implicit-coercion': ['error', { boolean: true, disallowTemplateShorthand: true, number: true, string: true }],
|
|
142
|
+
'no-lonely-if': 'error',
|
|
143
|
+
'no-loop-func': 'error',
|
|
144
|
+
'no-magic-numbers': 'off',
|
|
145
|
+
'no-unused-vars': 'error',
|
|
146
|
+
'no-var': 'error',
|
|
147
|
+
'object-shorthand': ['error', 'properties'],
|
|
148
|
+
'prefer-arrow-callback': 'error',
|
|
149
|
+
'prefer-const': 'error',
|
|
150
|
+
'prefer-promise-reject-errors': 'off',
|
|
151
|
+
'prefer-template': 'error',
|
|
152
|
+
'require-atomic-updates': 'error',
|
|
153
|
+
'require-await': 'error',
|
|
154
|
+
'yoda': 'error',
|
|
155
|
+
'import/newline-after-import': ['error', { count: 1 }],
|
|
156
|
+
'import/no-extraneous-dependencies': 'error'
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
files: ['**/*.{ts,tsx}'],
|
|
161
|
+
plugins: {
|
|
162
|
+
'@stylistic/ts': eslint_plugin_ts_1.default
|
|
163
|
+
},
|
|
164
|
+
rules: {
|
|
165
|
+
"no-unused-vars": "off",
|
|
166
|
+
'@stylistic/ts/member-delimiter-style': [
|
|
130
167
|
'error',
|
|
131
168
|
{
|
|
132
169
|
multiline: { delimiter: 'semi', requireLast: true },
|
|
@@ -134,23 +171,86 @@ module.exports = {
|
|
|
134
171
|
multilineDetection: 'brackets'
|
|
135
172
|
}
|
|
136
173
|
],
|
|
137
|
-
'@
|
|
138
|
-
'@
|
|
174
|
+
'@stylistic/ts/semi': ['error', 'always'],
|
|
175
|
+
'@stylistic/ts/space-infix-ops': ['error', { int32Hint: false }],
|
|
176
|
+
'@stylistic/ts/type-annotation-spacing': ['error', { before: false, after: true, overrides: { arrow: { before: true, after: true } } }],
|
|
177
|
+
'@typescript-eslint/explicit-function-return-type': 'warn',
|
|
178
|
+
'@typescript-eslint/explicit-member-accessibility': ['warn', { overrides: { constructors: 'no-public' } }],
|
|
179
|
+
'@typescript-eslint/naming-convention': [
|
|
180
|
+
'error',
|
|
181
|
+
{
|
|
182
|
+
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
183
|
+
leadingUnderscore: 'allow',
|
|
184
|
+
selector: 'variableLike'
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
188
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
139
189
|
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
|
140
|
-
'@typescript-eslint/semi': ['error', 'always'],
|
|
141
|
-
'@typescript-eslint/space-infix-ops': ['error', { int32Hint: false }],
|
|
142
|
-
'@typescript-eslint/type-annotation-spacing': ['error', { before: false, after: true, overrides: { arrow: { before: true, after: true } } }],
|
|
143
|
-
'camelcase': 'off',
|
|
144
190
|
'n/no-unsupported-features/es-builtins': 'off',
|
|
145
|
-
'n/no-unsupported-features/es-syntax': 'off'
|
|
146
|
-
'semi': 'off',
|
|
147
|
-
'space-infix-ops': 'off'
|
|
191
|
+
'n/no-unsupported-features/es-syntax': 'off'
|
|
148
192
|
}
|
|
149
193
|
}
|
|
150
|
-
]
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
194
|
+
];
|
|
195
|
+
if (params.useReact) {
|
|
196
|
+
configRules.push({
|
|
197
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
198
|
+
...(_a = eslint_plugin_react_1.default.configs.flat) === null || _a === void 0 ? void 0 : _a.recommended,
|
|
199
|
+
settings: {
|
|
200
|
+
react: {
|
|
201
|
+
version: 'detect'
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
rules: {
|
|
205
|
+
'react/jsx-boolean-value': ['error', 'always'],
|
|
206
|
+
'react/react-in-jsx-scope': 'off',
|
|
207
|
+
'react/sort-comp': 'error'
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
configRules.push({
|
|
211
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
212
|
+
plugins: {
|
|
213
|
+
'react-hooks': eslint_plugin_react_hooks_1.default,
|
|
214
|
+
'@stylistic/jsx': eslint_plugin_jsx_1.default
|
|
215
|
+
},
|
|
216
|
+
rules: {
|
|
217
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
218
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
219
|
+
'@stylistic/jsx/jsx-closing-bracket-location': ['error', 'line-aligned'],
|
|
220
|
+
'@stylistic/jsx/jsx-curly-spacing': ['error', 'never', { allowMultiline: false }],
|
|
221
|
+
'@stylistic/jsx/jsx-max-props-per-line': ['error', { maximum: 3 }],
|
|
222
|
+
'@stylistic/jsx/jsx-tag-spacing': ['error', { beforeSelfClosing: 'always' }],
|
|
223
|
+
'@stylistic/jsx/self-closing-comp': 'error'
|
|
224
|
+
}
|
|
225
|
+
});
|
|
155
226
|
}
|
|
156
|
-
|
|
227
|
+
else {
|
|
228
|
+
configRules.push(eslint_plugin_n_1.default.configs['flat/recommended'], {
|
|
229
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
230
|
+
rules: {
|
|
231
|
+
'n/global-require': 'error',
|
|
232
|
+
'n/no-missing-import': 'off',
|
|
233
|
+
'n/no-unpublished-import': 'off',
|
|
234
|
+
'n/no-unpublished-require': 'off',
|
|
235
|
+
'n/prefer-global/buffer': 'error',
|
|
236
|
+
'n/no-process-exit': 'off'
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
files: ['**/*.{ts,tsx}'],
|
|
240
|
+
rules: {
|
|
241
|
+
'n/no-unsupported-features/es-builtins': 'off',
|
|
242
|
+
'n/no-unsupported-features/es-syntax': 'off'
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
if (params.jsParser === ConfigParamsJsParser.BABEL) {
|
|
247
|
+
configRules.push({
|
|
248
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
249
|
+
languageOptions: {
|
|
250
|
+
parser: eslint_parser_1.default
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return configRules;
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,wBA0NC;AAlPD,oDAAkC;AAElC,sEAA4C;AAC5C,8EAAoD;AACpD,yEAA+C;AAC/C,0EAAiD;AACjD,yEAA2D;AAC3D,0FAA+D;AAE/D,mFAAsD;AACtD,mFAAsD;AACtD,qFAAwD;AACxD,sDAA8B;AAE9B,IAAK,oBAGJ;AAHD,WAAK,oBAAoB;IACrB,2CAAmB,CAAA;IACnB,uCAAe,CAAA;AACnB,CAAC,EAHI,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,oBAAoB,CAAC,KAAK,EAAE,CAAC;QACjD,WAAW,CAAC,IAAI,CACZ;YACI,KAAK,EAAE,CAAC,sBAAsB,CAAC;YAC/B,eAAe,EAAE;gBACb,MAAM,EAAE,uBAAW;aACtB;SACa,CACrB,CAAC;IACN,CAAC;IAED,OAAO,WAAW,CAAC;AACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ringieraxelspringer/eslint-config",
|
|
3
|
-
"version": "24.1.1",
|
|
4
3
|
"description": "Common Ringier Axel Springer ESLint configuration",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"repository": {},
|
|
7
6
|
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": "^18||^20||^22"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
12
13
|
"lint": "npm run lint:js",
|
|
13
|
-
"lint:js": "eslint
|
|
14
|
-
"lint:js:fix": "npm run lint:js -- --fix"
|
|
14
|
+
"lint:js": "eslint src/",
|
|
15
|
+
"lint:js:fix": "npm run lint:js -- --fix",
|
|
16
|
+
"prepare": "npm run build --silent",
|
|
17
|
+
"prebuild": "rimraf lib"
|
|
15
18
|
},
|
|
16
19
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
19
|
-
"eslint": "^
|
|
20
|
+
"@babel/core": "^7.26.0",
|
|
21
|
+
"@babel/eslint-parser": "^7.25.9",
|
|
22
|
+
"@eslint/js": "^9.0.0",
|
|
23
|
+
"@ringieraxelspringer/tsconfig": "^6.0.0",
|
|
24
|
+
"@stylistic/eslint-plugin-js": "^2.11.0",
|
|
25
|
+
"@stylistic/eslint-plugin-jsx": "^3.0.0",
|
|
26
|
+
"@stylistic/eslint-plugin-ts": "^3.0.0",
|
|
27
|
+
"@types/node": "^22.0.0",
|
|
28
|
+
"eslint": "^9.19.0",
|
|
20
29
|
"eslint-plugin-import": "^2.0.0",
|
|
21
30
|
"eslint-plugin-n": "^17.0.0",
|
|
22
31
|
"eslint-plugin-react": "^7.0.0",
|
|
23
|
-
"eslint-plugin-react-hooks": "^
|
|
24
|
-
"
|
|
32
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
33
|
+
"globals": "^16.0.0",
|
|
34
|
+
"rimraf": "^6.0.0",
|
|
35
|
+
"typescript": "^5.0.0",
|
|
36
|
+
"typescript-eslint": "^8.0.0"
|
|
25
37
|
},
|
|
26
|
-
"
|
|
27
|
-
"extends": "./lib/index.js"
|
|
28
|
-
}
|
|
38
|
+
"version": "25.0.0-alpha.5"
|
|
29
39
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import eslintJs from '@eslint/js';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
import eslintPluginN from 'eslint-plugin-n';
|
|
4
|
+
import eslintPluginReact from 'eslint-plugin-react';
|
|
5
|
+
import babelParser from '@babel/eslint-parser';
|
|
6
|
+
import typescriptEslint from 'typescript-eslint';
|
|
7
|
+
import * as eslintPluginImport from 'eslint-plugin-import';
|
|
8
|
+
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
|
|
9
|
+
|
|
10
|
+
import stylisticJs from '@stylistic/eslint-plugin-js';
|
|
11
|
+
import stylisticTs from '@stylistic/eslint-plugin-ts';
|
|
12
|
+
import stylisticJsx from '@stylistic/eslint-plugin-jsx';
|
|
13
|
+
import globals from 'globals';
|
|
14
|
+
|
|
15
|
+
enum ConfigParamsJsParser {
|
|
16
|
+
DEFAULT = 'default',
|
|
17
|
+
BABEL = 'babel'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface ConfigParams {
|
|
21
|
+
jsParser?: ConfigParamsJsParser;
|
|
22
|
+
useReact?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function config(params: ConfigParams = {}): Linter.Config[] {
|
|
26
|
+
const configRules: Linter.Config[] = [
|
|
27
|
+
eslintJs.configs.recommended as Linter.Config,
|
|
28
|
+
...typescriptEslint.configs.recommended as Linter.Config[],
|
|
29
|
+
{
|
|
30
|
+
files: ['**/*.{cjs,js,jsx,mjs}'],
|
|
31
|
+
plugins: {
|
|
32
|
+
'@stylistic/js': stylisticJs
|
|
33
|
+
},
|
|
34
|
+
rules: {
|
|
35
|
+
'@stylistic/js/semi': ['error', 'always'],
|
|
36
|
+
'@stylistic/js/space-infix-ops': 'error',
|
|
37
|
+
|
|
38
|
+
'camelcase': ['error', { ignoreDestructuring: true, properties: 'never' }]
|
|
39
|
+
}
|
|
40
|
+
} as Linter.Config,
|
|
41
|
+
{
|
|
42
|
+
files: ['**/*.{cjs,js,jsx,mjs,ts,tsx}'],
|
|
43
|
+
plugins: {
|
|
44
|
+
'import': eslintPluginImport,
|
|
45
|
+
'@stylistic/js': stylisticJs
|
|
46
|
+
},
|
|
47
|
+
languageOptions: {
|
|
48
|
+
ecmaVersion: 2025,
|
|
49
|
+
sourceType: 'module',
|
|
50
|
+
globals: {
|
|
51
|
+
...globals.browser,
|
|
52
|
+
...globals.jest,
|
|
53
|
+
...globals.node,
|
|
54
|
+
...globals.es2025
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
rules: {
|
|
58
|
+
'@stylistic/js/array-bracket-newline': ['error', 'consistent'],
|
|
59
|
+
'@stylistic/js/array-element-newline': ['error', 'consistent'],
|
|
60
|
+
'@stylistic/js/arrow-spacing': 'error',
|
|
61
|
+
'@stylistic/js/brace-style': 'error',
|
|
62
|
+
'@stylistic/js/comma-dangle': ['error', 'never'],
|
|
63
|
+
'@stylistic/js/comma-spacing': ['error', { before: false, after: true }],
|
|
64
|
+
'@stylistic/js/dot-location': ['error', 'property'],
|
|
65
|
+
'@stylistic/js/eol-last': ['error', 'always'],
|
|
66
|
+
'@stylistic/js/func-call-spacing': ['error', 'never'],
|
|
67
|
+
'@stylistic/js/generator-star-spacing': ['error', { before: false, after: true }],
|
|
68
|
+
'@stylistic/js/indent': [
|
|
69
|
+
'error',
|
|
70
|
+
4,
|
|
71
|
+
{ CallExpression: { arguments: 'off' }, flatTernaryExpressions: false, SwitchCase: 1, VariableDeclarator: 1 }
|
|
72
|
+
],
|
|
73
|
+
'@stylistic/js/jsx-quotes': ['error', 'prefer-double'],
|
|
74
|
+
'@stylistic/js/key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
|
75
|
+
'@stylistic/js/keyword-spacing': ['error', { before: true }],
|
|
76
|
+
'@stylistic/js/lines-between-class-members': ['error', 'always'],
|
|
77
|
+
'@stylistic/js/linebreak-style': ['error', 'unix'],
|
|
78
|
+
'@stylistic/js/max-len': ['error', { code: 160, comments: 160, ignoreRegExpLiterals: true, ignoreTemplateLiterals: true, ignoreUrls: true }],
|
|
79
|
+
'@stylistic/js/max-statements-per-line': ['error', { max: 1 }],
|
|
80
|
+
'@stylistic/js/multiline-ternary': ['error', 'always-multiline'],
|
|
81
|
+
'@stylistic/js/no-extra-semi': 'error',
|
|
82
|
+
'@stylistic/js/no-multi-spaces': 'error',
|
|
83
|
+
'@stylistic/js/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
84
|
+
'@stylistic/js/no-trailing-spaces': 'error',
|
|
85
|
+
'@stylistic/js/object-curly-spacing': ['error', 'always'],
|
|
86
|
+
'@stylistic/js/operator-linebreak': ['error', 'before'],
|
|
87
|
+
'@stylistic/js/padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }, { allowSingleLineBlocks: false }],
|
|
88
|
+
'@stylistic/js/padding-line-between-statements': [
|
|
89
|
+
'error',
|
|
90
|
+
{ blankLine: 'always', prev: ['block', 'block-like', 'class', 'directive'], next: '*' },
|
|
91
|
+
{ blankLine: 'always', prev: '*', next: ['block', 'block-like', 'class', 'return'] },
|
|
92
|
+
{ blankLine: 'never', prev: 'case', next: ['case', 'default'] }
|
|
93
|
+
],
|
|
94
|
+
'@stylistic/js/quote-props': ['error', 'consistent-as-needed'],
|
|
95
|
+
'@stylistic/js/quotes': ['error', 'single'],
|
|
96
|
+
'@stylistic/js/semi-spacing': ['error', { after: true, before: false }],
|
|
97
|
+
'@stylistic/js/space-before-blocks': 'error',
|
|
98
|
+
'@stylistic/js/space-before-function-paren': ['error', { anonymous: 'never', asyncArrow: 'always', named: 'never' }],
|
|
99
|
+
'@stylistic/js/space-in-parens': ['error', 'never'],
|
|
100
|
+
|
|
101
|
+
'camelcase': ['error', { ignoreDestructuring: true, properties: 'never' }],
|
|
102
|
+
'curly': 'error',
|
|
103
|
+
'dot-notation': 'error',
|
|
104
|
+
'eqeqeq': ['error', 'always'],
|
|
105
|
+
'max-classes-per-file': ['warn', { ignoreExpressions: true, max: 1 }],
|
|
106
|
+
'no-alert': 'error',
|
|
107
|
+
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug'] }],
|
|
108
|
+
'no-duplicate-imports': 'error',
|
|
109
|
+
'no-empty': 'error',
|
|
110
|
+
'no-empty-function': 'error',
|
|
111
|
+
'no-implicit-coercion': ['error', { boolean: true, disallowTemplateShorthand: true, number: true, string: true }],
|
|
112
|
+
'no-lonely-if': 'error',
|
|
113
|
+
'no-loop-func': 'error',
|
|
114
|
+
'no-magic-numbers': 'off',
|
|
115
|
+
'no-unused-vars': 'error',
|
|
116
|
+
'no-var': 'error',
|
|
117
|
+
'object-shorthand': ['error', 'properties'],
|
|
118
|
+
'prefer-arrow-callback': 'error',
|
|
119
|
+
'prefer-const': 'error',
|
|
120
|
+
'prefer-promise-reject-errors': 'off',
|
|
121
|
+
'prefer-template': 'error',
|
|
122
|
+
'require-atomic-updates': 'error',
|
|
123
|
+
'require-await': 'error',
|
|
124
|
+
'yoda': 'error',
|
|
125
|
+
|
|
126
|
+
'import/newline-after-import': ['error', { count: 1 }],
|
|
127
|
+
'import/no-extraneous-dependencies': 'error'
|
|
128
|
+
}
|
|
129
|
+
} as Linter.Config,
|
|
130
|
+
{
|
|
131
|
+
files: ['**/*.{ts,tsx}'],
|
|
132
|
+
plugins: {
|
|
133
|
+
'@stylistic/ts': stylisticTs
|
|
134
|
+
},
|
|
135
|
+
rules: {
|
|
136
|
+
"no-unused-vars": "off",
|
|
137
|
+
|
|
138
|
+
'@stylistic/ts/member-delimiter-style': [
|
|
139
|
+
'error',
|
|
140
|
+
{
|
|
141
|
+
multiline: { delimiter: 'semi', requireLast: true },
|
|
142
|
+
singleline: { delimiter: 'semi', requireLast: true },
|
|
143
|
+
multilineDetection: 'brackets'
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
'@stylistic/ts/semi': ['error', 'always'],
|
|
147
|
+
'@stylistic/ts/space-infix-ops': ['error', { int32Hint: false }],
|
|
148
|
+
'@stylistic/ts/type-annotation-spacing': ['error', { before: false, after: true, overrides: { arrow: { before: true, after: true } } }],
|
|
149
|
+
|
|
150
|
+
'@typescript-eslint/explicit-function-return-type': 'warn',
|
|
151
|
+
'@typescript-eslint/explicit-member-accessibility': ['warn', { overrides: { constructors: 'no-public' } }],
|
|
152
|
+
'@typescript-eslint/naming-convention': [
|
|
153
|
+
'error',
|
|
154
|
+
{
|
|
155
|
+
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
156
|
+
leadingUnderscore: 'allow',
|
|
157
|
+
selector: 'variableLike'
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
161
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
162
|
+
'@typescript-eslint/prefer-ts-expect-error': 'error',
|
|
163
|
+
|
|
164
|
+
'n/no-unsupported-features/es-builtins': 'off',
|
|
165
|
+
'n/no-unsupported-features/es-syntax': 'off'
|
|
166
|
+
}
|
|
167
|
+
} as Linter.Config
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
if (params.useReact) {
|
|
171
|
+
configRules.push(
|
|
172
|
+
{
|
|
173
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
174
|
+
...eslintPluginReact.configs.flat?.recommended,
|
|
175
|
+
settings: {
|
|
176
|
+
react: {
|
|
177
|
+
version: 'detect'
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
rules: {
|
|
181
|
+
'react/jsx-boolean-value': ['error', 'always'],
|
|
182
|
+
'react/react-in-jsx-scope': 'off',
|
|
183
|
+
'react/sort-comp': 'error'
|
|
184
|
+
}
|
|
185
|
+
} as Linter.Config
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
configRules.push(
|
|
189
|
+
{
|
|
190
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
191
|
+
plugins: {
|
|
192
|
+
'react-hooks': eslintPluginReactHooks,
|
|
193
|
+
'@stylistic/jsx': stylisticJsx
|
|
194
|
+
},
|
|
195
|
+
rules: {
|
|
196
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
197
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
198
|
+
|
|
199
|
+
'@stylistic/jsx/jsx-closing-bracket-location': ['error', 'line-aligned'],
|
|
200
|
+
'@stylistic/jsx/jsx-curly-spacing': ['error', 'never', { allowMultiline: false }],
|
|
201
|
+
'@stylistic/jsx/jsx-max-props-per-line': ['error', { maximum: 3 }],
|
|
202
|
+
'@stylistic/jsx/jsx-tag-spacing': ['error', { beforeSelfClosing: 'always' }],
|
|
203
|
+
'@stylistic/jsx/self-closing-comp': 'error'
|
|
204
|
+
}
|
|
205
|
+
} as Linter.Config
|
|
206
|
+
);
|
|
207
|
+
} else {
|
|
208
|
+
configRules.push(
|
|
209
|
+
eslintPluginN.configs['flat/recommended'] as Linter.Config,
|
|
210
|
+
{
|
|
211
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
212
|
+
rules: {
|
|
213
|
+
'n/global-require': 'error',
|
|
214
|
+
'n/no-missing-import': 'off',
|
|
215
|
+
'n/no-unpublished-import': 'off',
|
|
216
|
+
'n/no-unpublished-require': 'off',
|
|
217
|
+
'n/prefer-global/buffer': 'error',
|
|
218
|
+
'n/no-process-exit': 'off'
|
|
219
|
+
}
|
|
220
|
+
} as Linter.Config,
|
|
221
|
+
{
|
|
222
|
+
files: ['**/*.{ts,tsx}'],
|
|
223
|
+
rules: {
|
|
224
|
+
'n/no-unsupported-features/es-builtins': 'off',
|
|
225
|
+
'n/no-unsupported-features/es-syntax': 'off'
|
|
226
|
+
}
|
|
227
|
+
} as Linter.Config
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (params.jsParser === ConfigParamsJsParser.BABEL) {
|
|
232
|
+
configRules.push(
|
|
233
|
+
{
|
|
234
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
235
|
+
languageOptions: {
|
|
236
|
+
parser: babelParser
|
|
237
|
+
}
|
|
238
|
+
} as Linter.Config
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return configRules;
|
|
243
|
+
}
|
package/tsconfig.json
ADDED