@o3r/eslint-config 11.6.0-prerelease.8
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/LICENSE +26 -0
- package/README.md +38 -0
- package/collection.json +11 -0
- package/package.json +221 -0
- package/schematics/ng-add/eslint/index.d.ts +8 -0
- package/schematics/ng-add/eslint/index.d.ts.map +1 -0
- package/schematics/ng-add/eslint/index.js +92 -0
- package/schematics/ng-add/eslint/index.js.map +1 -0
- package/schematics/ng-add/eslint/templates/project/eslint.config.__extension__.template +10 -0
- package/schematics/ng-add/eslint/templates/project/eslint.local.config.__extension__.template +27 -0
- package/schematics/ng-add/eslint/templates/workspace/eslint.config.__extension__.template +67 -0
- package/schematics/ng-add/eslint/templates/workspace/eslint.local.config.__extension__.template +22 -0
- package/schematics/ng-add/eslint/templates/workspace/eslint.shared.config.__extension__.template +41 -0
- package/schematics/ng-add/index.d.ts +8 -0
- package/schematics/ng-add/index.d.ts.map +1 -0
- package/schematics/ng-add/index.js +128 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.d.ts +10 -0
- package/schematics/ng-add/schema.d.ts.map +1 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +28 -0
- package/schematics/ng-add/tsconfig/index.d.ts +8 -0
- package/schematics/ng-add/tsconfig/index.d.ts.map +1 -0
- package/schematics/ng-add/tsconfig/index.js +25 -0
- package/schematics/ng-add/tsconfig/index.js.map +1 -0
- package/schematics/ng-add/tsconfig/templates/tsconfig.eslint.json.template +6 -0
- package/schematics/ng-add/vscode/index.d.ts +6 -0
- package/schematics/ng-add/vscode/index.d.ts.map +1 -0
- package/schematics/ng-add/vscode/index.js +35 -0
- package/schematics/ng-add/vscode/index.js.map +1 -0
- package/schematics/package.json +3 -0
- package/src/rules/base.cjs +17 -0
- package/src/rules/template/angular.cjs +27 -0
- package/src/rules/template/otter.cjs +20 -0
- package/src/rules/template.cjs +23 -0
- package/src/rules/typescript/comments.cjs +27 -0
- package/src/rules/typescript/eslint-angular.cjs +36 -0
- package/src/rules/typescript/eslint-typescript.cjs +145 -0
- package/src/rules/typescript/eslint.cjs +146 -0
- package/src/rules/typescript/import-newlines.cjs +23 -0
- package/src/rules/typescript/import.cjs +29 -0
- package/src/rules/typescript/jest.cjs +26 -0
- package/src/rules/typescript/jsdoc.cjs +53 -0
- package/src/rules/typescript/otter.cjs +24 -0
- package/src/rules/typescript/prefer-arrow.cjs +25 -0
- package/src/rules/typescript/sort-export-all.cjs +24 -0
- package/src/rules/typescript/stylistic.cjs +101 -0
- package/src/rules/typescript/unicorn.cjs +51 -0
- package/src/rules/typescript/unused-imports.cjs +20 -0
- package/src/rules/typescript.cjs +138 -0
- package/src/rules/utils.cjs +21 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const eslint = require('@eslint/js');
|
|
3
|
+
const { convertWarningsToErrors } = require('../utils.cjs');
|
|
4
|
+
|
|
5
|
+
const defaultNewCapOptions = {
|
|
6
|
+
newIsCap: true,
|
|
7
|
+
capIsNew: true,
|
|
8
|
+
properties: true,
|
|
9
|
+
capIsNewExceptions: [
|
|
10
|
+
'AsyncInput',
|
|
11
|
+
'Component',
|
|
12
|
+
'Directive',
|
|
13
|
+
'HostBinding',
|
|
14
|
+
'HostListener',
|
|
15
|
+
'Inject',
|
|
16
|
+
'Injectable',
|
|
17
|
+
'Input',
|
|
18
|
+
'Localization',
|
|
19
|
+
'NgModule',
|
|
20
|
+
'Optional',
|
|
21
|
+
'Output',
|
|
22
|
+
'Pipe',
|
|
23
|
+
'ViewChild',
|
|
24
|
+
'ViewChildren',
|
|
25
|
+
'SkipSelf',
|
|
26
|
+
'Host',
|
|
27
|
+
'ContentChildren',
|
|
28
|
+
'O3rComponent',
|
|
29
|
+
'ConfigObserver',
|
|
30
|
+
'O3rConfig'
|
|
31
|
+
]
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
|
|
35
|
+
*/
|
|
36
|
+
const config = [
|
|
37
|
+
{
|
|
38
|
+
name: '@o3r/eslint-config/eslint-js',
|
|
39
|
+
files: [
|
|
40
|
+
'**/*.{c,m,}{t,j}s'
|
|
41
|
+
],
|
|
42
|
+
rules: {
|
|
43
|
+
...convertWarningsToErrors(eslint.configs.recommended),
|
|
44
|
+
complexity: 'off',
|
|
45
|
+
'constructor-super': 'error',
|
|
46
|
+
curly: 'error',
|
|
47
|
+
'dot-notation': 'error',
|
|
48
|
+
eqeqeq: [
|
|
49
|
+
'error',
|
|
50
|
+
'smart'
|
|
51
|
+
],
|
|
52
|
+
'getter-return': 'error',
|
|
53
|
+
'guard-for-in': 'error',
|
|
54
|
+
'id-denylist': ['error',
|
|
55
|
+
'any',
|
|
56
|
+
'Number',
|
|
57
|
+
'String',
|
|
58
|
+
'string',
|
|
59
|
+
'Boolean',
|
|
60
|
+
'boolean',
|
|
61
|
+
'Undefined',
|
|
62
|
+
'undefined'
|
|
63
|
+
],
|
|
64
|
+
'id-match': 'error',
|
|
65
|
+
'max-classes-per-file': 'off',
|
|
66
|
+
'new-cap': [
|
|
67
|
+
'error',
|
|
68
|
+
defaultNewCapOptions
|
|
69
|
+
],
|
|
70
|
+
'no-alert': 'error',
|
|
71
|
+
'no-bitwise': 'error',
|
|
72
|
+
'no-caller': 'error',
|
|
73
|
+
'no-console': 'error',
|
|
74
|
+
'no-dupe-args': 'error',
|
|
75
|
+
'no-dupe-keys': 'error',
|
|
76
|
+
'no-empty': 'off',
|
|
77
|
+
'no-empty-function': 'off',
|
|
78
|
+
'no-eval': 'error',
|
|
79
|
+
'no-func-assign': 'error',
|
|
80
|
+
'no-import-assign': 'error',
|
|
81
|
+
'no-inner-declarations': 'error',
|
|
82
|
+
'no-invalid-this': 'off',
|
|
83
|
+
'no-iterator': 'error',
|
|
84
|
+
'no-loop-func': 'error',
|
|
85
|
+
'no-multi-str': 'error',
|
|
86
|
+
'no-new-native-nonconstructor': 'error',
|
|
87
|
+
'no-new-wrappers': 'error',
|
|
88
|
+
'no-obj-calls': 'error',
|
|
89
|
+
'no-proto': 'error',
|
|
90
|
+
'no-restricted-imports': ['error', {
|
|
91
|
+
patterns: [
|
|
92
|
+
'rxjs/internal/*'
|
|
93
|
+
]
|
|
94
|
+
}],
|
|
95
|
+
'no-sequences': 'error',
|
|
96
|
+
'no-setter-return': 'error',
|
|
97
|
+
'no-shadow': 'off',
|
|
98
|
+
'no-this-before-super': 'error',
|
|
99
|
+
'no-undef': 'error',
|
|
100
|
+
'no-undef-init': 'error',
|
|
101
|
+
'no-underscore-dangle': [
|
|
102
|
+
'error',
|
|
103
|
+
{
|
|
104
|
+
allowAfterThis: true
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
'no-unreachable': 'error',
|
|
108
|
+
'no-unsafe-negation': 'error',
|
|
109
|
+
'object-shorthand': 'off',
|
|
110
|
+
'one-var': [
|
|
111
|
+
'error',
|
|
112
|
+
'never'
|
|
113
|
+
],
|
|
114
|
+
radix: 'error',
|
|
115
|
+
'sort-imports': [
|
|
116
|
+
'error',
|
|
117
|
+
{
|
|
118
|
+
allowSeparatedGroups: false,
|
|
119
|
+
ignoreDeclarationSort: true,
|
|
120
|
+
ignoreCase: true
|
|
121
|
+
}
|
|
122
|
+
],
|
|
123
|
+
strict: [
|
|
124
|
+
'error',
|
|
125
|
+
'global'
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: '@o3r/eslint-config/eslint-js/typescript',
|
|
131
|
+
files: [
|
|
132
|
+
'**/*.{c,m,}ts'
|
|
133
|
+
],
|
|
134
|
+
rules: {
|
|
135
|
+
'new-cap': [
|
|
136
|
+
'error',
|
|
137
|
+
{
|
|
138
|
+
...defaultNewCapOptions,
|
|
139
|
+
newIsCap: false
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
module.exports = config;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const importNewlinesPlugin = require('eslint-plugin-import-newlines');
|
|
3
|
+
|
|
4
|
+
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
|
|
5
|
+
const config = [
|
|
6
|
+
{
|
|
7
|
+
name: '@o3r/eslint-config/import-newlines',
|
|
8
|
+
files: [
|
|
9
|
+
'**/*.{c,m,}{t,j}s'
|
|
10
|
+
],
|
|
11
|
+
plugins: {
|
|
12
|
+
'import-newlines': importNewlinesPlugin
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
'import-newlines/enforce': [
|
|
16
|
+
'error',
|
|
17
|
+
0
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
module.exports = config;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const importPlugin = require('eslint-plugin-import');
|
|
3
|
+
const { convertWarningsToErrors } = require('../utils.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
|
|
7
|
+
*/
|
|
8
|
+
const config = [
|
|
9
|
+
{
|
|
10
|
+
name: '@o3r/eslint-config/import',
|
|
11
|
+
files: [
|
|
12
|
+
'**/*.{c,m,}{t,j}s'
|
|
13
|
+
],
|
|
14
|
+
rules: {
|
|
15
|
+
...convertWarningsToErrors(importPlugin.flatConfigs.recommended),
|
|
16
|
+
...convertWarningsToErrors(importPlugin.flatConfigs.typescript),
|
|
17
|
+
'import/first': 'error',
|
|
18
|
+
'import/newline-after-import': 'error',
|
|
19
|
+
'import/no-cycle': 'error',
|
|
20
|
+
'import/no-unresolved': 'error',
|
|
21
|
+
'import/order': ['error', {
|
|
22
|
+
'newlines-between': 'never',
|
|
23
|
+
alphabetize: { order: 'asc', caseInsensitive: true }
|
|
24
|
+
}]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
module.exports = config;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const jest = require('eslint-plugin-jest');
|
|
3
|
+
const { convertWarningsToErrors } = require('../utils.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
|
|
7
|
+
*/
|
|
8
|
+
const config = [
|
|
9
|
+
{
|
|
10
|
+
name: '@o3r/eslint-config/jest',
|
|
11
|
+
files: [
|
|
12
|
+
'**/*.{c,m,}{t,j}s'
|
|
13
|
+
],
|
|
14
|
+
rules: {
|
|
15
|
+
...convertWarningsToErrors(jest.configs['flat/recommended']),
|
|
16
|
+
'jest/expect-expect': [
|
|
17
|
+
'error',
|
|
18
|
+
{
|
|
19
|
+
assertFunctionNames: ['expect', 'expectObservable']
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
module.exports = config;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const jsdoc = require('eslint-plugin-jsdoc');
|
|
3
|
+
const { convertWarningsToErrors } = require('../utils.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
|
|
7
|
+
*/
|
|
8
|
+
const config = [
|
|
9
|
+
{
|
|
10
|
+
name: '@o3r/eslint-config/jsdoc',
|
|
11
|
+
files: [
|
|
12
|
+
'**/*.{c,m,}{t,j}s'
|
|
13
|
+
],
|
|
14
|
+
rules: {
|
|
15
|
+
...convertWarningsToErrors(jsdoc.configs['flat/recommended']),
|
|
16
|
+
// TODO fix issue with ESLint v9+
|
|
17
|
+
// 'jsdoc/check-examples': ['error', {
|
|
18
|
+
// 'exampleCodeRegex': '^```(?:javascript|typescript|java|json|yaml|shell)?([\\s\\S]*)```\\s*$'
|
|
19
|
+
// }],
|
|
20
|
+
'jsdoc/check-tag-names': [
|
|
21
|
+
'error',
|
|
22
|
+
{
|
|
23
|
+
definedTags: ['note', 'title', 'o3rCategory', 'o3rCategories', 'o3rWidget', 'o3rWidgetParam', 'o3rRequired']
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
'jsdoc/no-defaults': 'off',
|
|
27
|
+
'jsdoc/no-undefined-types': 'off',
|
|
28
|
+
'jsdoc/require-description': 'error',
|
|
29
|
+
'jsdoc/require-jsdoc': [
|
|
30
|
+
'error',
|
|
31
|
+
{
|
|
32
|
+
publicOnly: true
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
'jsdoc/require-param-description': 'off',
|
|
36
|
+
'jsdoc/require-param-type': 'off',
|
|
37
|
+
'jsdoc/require-property-type': 'off',
|
|
38
|
+
'jsdoc/require-returns': 'off',
|
|
39
|
+
'jsdoc/require-returns-type': 'off'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: '@o3r/eslint-config/jsdoc/js',
|
|
44
|
+
files: ['**/*.{c,m,}js'],
|
|
45
|
+
rules: {
|
|
46
|
+
'jsdoc/require-param-type': 'error',
|
|
47
|
+
'jsdoc/require-returns-description': 'off',
|
|
48
|
+
'jsdoc/require-returns-type': 'error'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
module.exports = config;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const o3rBaseConfig = require('../base.cjs');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the @o3r typescript recommended rules
|
|
6
|
+
* @param {import('@typescript-eslint/utils').TSESLint.FlatConfig.Plugin} plugin
|
|
7
|
+
* @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} config
|
|
8
|
+
*/
|
|
9
|
+
const o3rTypescriptRecommended = (plugin) => [
|
|
10
|
+
o3rBaseConfig(plugin),
|
|
11
|
+
{
|
|
12
|
+
name: '@o3r/eslint-config/typescript-recommended',
|
|
13
|
+
// Same files as the ones asked by `typescript-eslint` recommendation
|
|
14
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
|
|
15
|
+
rules: {
|
|
16
|
+
'@o3r/matching-configuration-name': 'error',
|
|
17
|
+
'@o3r/no-folder-import-for-module': 'error',
|
|
18
|
+
'@o3r/no-multiple-type-configuration-property': 'error',
|
|
19
|
+
'@o3r/o3r-categories-tags': 'error'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
module.exports = o3rTypescriptRecommended;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const preferArrowPlugin = require('eslint-plugin-prefer-arrow');
|
|
3
|
+
|
|
4
|
+
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
|
|
5
|
+
const config = [
|
|
6
|
+
{
|
|
7
|
+
name: '@o3r/eslint-config/prefer-arrow',
|
|
8
|
+
files: [
|
|
9
|
+
'**/*.{c,m,}{t,j}s'
|
|
10
|
+
],
|
|
11
|
+
plugins: {
|
|
12
|
+
'prefer-arrow': preferArrowPlugin
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
'prefer-arrow/prefer-arrow-functions': [
|
|
16
|
+
'error',
|
|
17
|
+
{
|
|
18
|
+
allowStandaloneDeclarations: true
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
module.exports = config;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
module.exports = [];
|
|
3
|
+
// TODO: reactivate once https://github.com/nirtamir2/eslint-plugin-sort-export-all/issues/18 is fixed
|
|
4
|
+
// const sortExportAll = require('eslint-plugin-sort-export-all');
|
|
5
|
+
|
|
6
|
+
// /**
|
|
7
|
+
// * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
|
|
8
|
+
// */
|
|
9
|
+
// const config = [
|
|
10
|
+
// {
|
|
11
|
+
// name: '@o3r/eslint-config/sort-export-all',
|
|
12
|
+
// plugins: {
|
|
13
|
+
// 'sort-export-all': sortExportAll
|
|
14
|
+
// },
|
|
15
|
+
// files: [
|
|
16
|
+
// '**/*.{c,m,}{t,j}s'
|
|
17
|
+
// ],
|
|
18
|
+
// rules: {
|
|
19
|
+
// 'sort-export-all/sort-export-all': 'error'
|
|
20
|
+
// }
|
|
21
|
+
// }
|
|
22
|
+
// ];
|
|
23
|
+
|
|
24
|
+
// module.exports = config;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const stylistic = require('@stylistic/eslint-plugin');
|
|
3
|
+
const { convertWarningsToErrors } = require('../utils.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
|
|
7
|
+
*/
|
|
8
|
+
const config = [
|
|
9
|
+
{
|
|
10
|
+
name: '@o3r/eslint-config/stylistic',
|
|
11
|
+
files: [
|
|
12
|
+
'**/*.{c,m,}{t,j}s'
|
|
13
|
+
],
|
|
14
|
+
rules: {
|
|
15
|
+
...convertWarningsToErrors(stylistic.configs['recommended-flat']),
|
|
16
|
+
'@stylistic/arrow-parens': ['error', 'always'],
|
|
17
|
+
'@stylistic/brace-style': ['error', '1tbs'],
|
|
18
|
+
'@stylistic/comma-dangle': ['error', {
|
|
19
|
+
arrays: 'never',
|
|
20
|
+
objects: 'never',
|
|
21
|
+
imports: 'always-multiline',
|
|
22
|
+
exports: 'always-multiline',
|
|
23
|
+
functions: 'never'
|
|
24
|
+
}],
|
|
25
|
+
'@stylistic/indent': [
|
|
26
|
+
'error',
|
|
27
|
+
2,
|
|
28
|
+
{
|
|
29
|
+
FunctionDeclaration: {
|
|
30
|
+
parameters: 'off'
|
|
31
|
+
},
|
|
32
|
+
SwitchCase: 1
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
'@stylistic/linebreak-style': [
|
|
36
|
+
'error',
|
|
37
|
+
'unix'
|
|
38
|
+
],
|
|
39
|
+
'@stylistic/max-len': [
|
|
40
|
+
'error',
|
|
41
|
+
{
|
|
42
|
+
code: 200
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
'@stylistic/member-delimiter-style': [
|
|
46
|
+
'error',
|
|
47
|
+
{
|
|
48
|
+
multiline: {
|
|
49
|
+
delimiter: 'semi',
|
|
50
|
+
requireLast: true
|
|
51
|
+
},
|
|
52
|
+
singleline: {
|
|
53
|
+
delimiter: 'semi',
|
|
54
|
+
requireLast: false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
'@stylistic/no-extra-semi': 'error',
|
|
59
|
+
'@stylistic/no-multiple-empty-lines': 'error',
|
|
60
|
+
'@stylistic/operator-linebreak': [
|
|
61
|
+
'error',
|
|
62
|
+
'before',
|
|
63
|
+
{
|
|
64
|
+
overrides: { '=': 'none' }
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
'@stylistic/quotes': [
|
|
68
|
+
'error',
|
|
69
|
+
'single',
|
|
70
|
+
{
|
|
71
|
+
avoidEscape: true,
|
|
72
|
+
allowTemplateLiterals: true
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
'@stylistic/quote-props': [
|
|
76
|
+
'error',
|
|
77
|
+
'as-needed'
|
|
78
|
+
],
|
|
79
|
+
'@stylistic/semi': [
|
|
80
|
+
'error',
|
|
81
|
+
'always'
|
|
82
|
+
],
|
|
83
|
+
'@stylistic/space-unary-ops': 'error',
|
|
84
|
+
'@stylistic/spaced-comment': [
|
|
85
|
+
'error',
|
|
86
|
+
'always',
|
|
87
|
+
{
|
|
88
|
+
markers: [
|
|
89
|
+
'/'
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
'@stylistic/wrap-iife': [
|
|
94
|
+
'error',
|
|
95
|
+
'inside'
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
module.exports = config;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const unicorn = require('eslint-plugin-unicorn');
|
|
3
|
+
const { convertWarningsToErrors } = require('../utils.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
|
|
7
|
+
*/
|
|
8
|
+
const config = [
|
|
9
|
+
{
|
|
10
|
+
name: '@o3r/eslint-config/unicorn',
|
|
11
|
+
files: [
|
|
12
|
+
'**/*.{c,m,}{t,j}s'
|
|
13
|
+
],
|
|
14
|
+
rules: {
|
|
15
|
+
...convertWarningsToErrors(unicorn.configs['flat/recommended']),
|
|
16
|
+
'unicorn/catch-error-name': 'off',
|
|
17
|
+
'unicorn/consistent-function-scoping': 'off',
|
|
18
|
+
'unicorn/filename-case': [
|
|
19
|
+
'error',
|
|
20
|
+
{
|
|
21
|
+
case: 'kebabCase',
|
|
22
|
+
ignore: [
|
|
23
|
+
'^public_api.[cm]?ts$'
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
'unicorn/import-style': 'off',
|
|
28
|
+
'unicorn/no-array-for-each': 'off',
|
|
29
|
+
'unicorn/no-array-reduce': 'off',
|
|
30
|
+
'unicorn/no-await-expression-member': 'off',
|
|
31
|
+
'unicorn/no-null': 'off',
|
|
32
|
+
'unicorn/no-typeof-undefined': 'off',
|
|
33
|
+
'unicorn/no-useless-undefined': 'off',
|
|
34
|
+
'unicorn/no-useless-promise-resolve-reject': 'off',
|
|
35
|
+
'unicorn/prefer-code-point': 'off',
|
|
36
|
+
'unicorn/prefer-dom-node-text-content': 'off',
|
|
37
|
+
'unicorn/prefer-global-this': 'off',
|
|
38
|
+
'unicorn/prefer-module': 'off',
|
|
39
|
+
'unicorn/prefer-set-has': 'off',
|
|
40
|
+
'unicorn/prefer-spread': 'off',
|
|
41
|
+
'unicorn/prefer-string-raw': 'off',
|
|
42
|
+
'unicorn/prefer-string-replace-all': 'off',
|
|
43
|
+
'unicorn/prefer-string-slice': 'off',
|
|
44
|
+
'unicorn/prefer-top-level-await': 'off',
|
|
45
|
+
'unicorn/prefer-type-error': 'off',
|
|
46
|
+
'unicorn/prevent-abbreviations': 'off'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
module.exports = config;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const unusedImportsPlugin = require('eslint-plugin-unused-imports');
|
|
3
|
+
|
|
4
|
+
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
|
|
5
|
+
const config = [
|
|
6
|
+
{
|
|
7
|
+
name: '@o3r/eslint-config/unused-imports',
|
|
8
|
+
files: [
|
|
9
|
+
'**/*.{c,m,}{t,j}s'
|
|
10
|
+
],
|
|
11
|
+
plugins: {
|
|
12
|
+
'unused-imports': unusedImportsPlugin
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
'unused-imports/no-unused-imports': 'error'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
module.exports = config;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const eslint = require('@eslint/js');
|
|
3
|
+
const comments = require('@eslint-community/eslint-plugin-eslint-comments/configs');
|
|
4
|
+
const o3r = require('@o3r/eslint-plugin');
|
|
5
|
+
const stylistic = require('@stylistic/eslint-plugin');
|
|
6
|
+
const angular = require('angular-eslint');
|
|
7
|
+
const importPlugin = require('eslint-plugin-import');
|
|
8
|
+
const jsdoc = require('eslint-plugin-jsdoc');
|
|
9
|
+
const unicorn = require('eslint-plugin-unicorn');
|
|
10
|
+
const typescript = require('typescript-eslint');
|
|
11
|
+
const commentsConfigOverrides = require('./typescript/comments.cjs');
|
|
12
|
+
const angularConfigOverrides = require('./typescript/eslint-angular.cjs');
|
|
13
|
+
const typescriptConfigOverrides = require('./typescript/eslint-typescript.cjs');
|
|
14
|
+
const eslintConfigOverrides = require('./typescript/eslint.cjs');
|
|
15
|
+
const importNewlinesConfig = require('./typescript/import-newlines.cjs');
|
|
16
|
+
const importConfig = require('./typescript/import.cjs');
|
|
17
|
+
const jsdocConfigOverrides = require('./typescript/jsdoc.cjs');
|
|
18
|
+
const otterConfig = require('./typescript/otter.cjs');
|
|
19
|
+
const preferArrowConfig = require('./typescript/prefer-arrow.cjs');
|
|
20
|
+
// TODO: reactivate once https://github.com/nirtamir2/eslint-plugin-sort-export-all/issues/18 is fixed
|
|
21
|
+
// const sortExportAll = require('./typescript/sort-export-all.cjs');
|
|
22
|
+
const stylisticConfig = require('./typescript/stylistic.cjs');
|
|
23
|
+
const unicornConfig = require('./typescript/unicorn.cjs');
|
|
24
|
+
const unusedImportsConfig = require('./typescript/unused-imports.cjs');
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get the jest config if dependency is present
|
|
28
|
+
* @param {'recommended' | 'overrides'} type
|
|
29
|
+
* @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} config
|
|
30
|
+
*/
|
|
31
|
+
const getJestConfig = (type) => {
|
|
32
|
+
try {
|
|
33
|
+
require.resolve('jest');
|
|
34
|
+
return type === 'overrides'
|
|
35
|
+
? require('./typescript/jest.cjs')
|
|
36
|
+
: [{
|
|
37
|
+
// Name added for debugging purpose with @eslint/config-inspector
|
|
38
|
+
name: 'jest/flat-recommended',
|
|
39
|
+
files: [
|
|
40
|
+
'**/*.{c,m,}{t,j}s'
|
|
41
|
+
],
|
|
42
|
+
...require('eslint-plugin-jest').configs['flat/recommended']
|
|
43
|
+
}];
|
|
44
|
+
} catch {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
|
|
51
|
+
*/
|
|
52
|
+
const configArray = [
|
|
53
|
+
{
|
|
54
|
+
// Name added for debugging purpose with @eslint/config-inspector
|
|
55
|
+
name: '@eslint/js/recommended',
|
|
56
|
+
files: [
|
|
57
|
+
'**/*.{c,m,}{t,j}s'
|
|
58
|
+
],
|
|
59
|
+
...eslint.configs.recommended
|
|
60
|
+
},
|
|
61
|
+
...[
|
|
62
|
+
...typescript.configs.recommended,
|
|
63
|
+
...typescript.configs.recommendedTypeChecked,
|
|
64
|
+
...angular.configs.tsRecommended
|
|
65
|
+
].map((config) => ({
|
|
66
|
+
// Same files as the ones asked by `typescript-eslint/eslint-recommended`
|
|
67
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
|
|
68
|
+
...config
|
|
69
|
+
})),
|
|
70
|
+
{
|
|
71
|
+
files: [
|
|
72
|
+
'**/*.{c,m,}{t,j}s'
|
|
73
|
+
],
|
|
74
|
+
...jsdoc.configs['flat/recommended']
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
// Name added for debugging purpose with @eslint/config-inspector
|
|
78
|
+
name: 'stylistic/recommended',
|
|
79
|
+
files: [
|
|
80
|
+
'**/*.{c,m,}{t,j}s'
|
|
81
|
+
],
|
|
82
|
+
...stylistic.configs['recommended-flat']
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
files: [
|
|
86
|
+
'**/*.{c,m,}{t,j}s'
|
|
87
|
+
],
|
|
88
|
+
...unicorn.configs['flat/recommended']
|
|
89
|
+
},
|
|
90
|
+
...(getJestConfig('recommended')),
|
|
91
|
+
{
|
|
92
|
+
// Name added for debugging purpose with @eslint/config-inspector
|
|
93
|
+
name: 'import/recommended',
|
|
94
|
+
files: ['**/*.{c,m,}{t,j}s'],
|
|
95
|
+
...importPlugin.flatConfigs.recommended
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
// Name added for debugging purpose with @eslint/config-inspector
|
|
99
|
+
name: 'import/typescript',
|
|
100
|
+
files: ['**/*.{c,m,}ts'],
|
|
101
|
+
...importPlugin.flatConfigs.typescript
|
|
102
|
+
},
|
|
103
|
+
comments.recommended,
|
|
104
|
+
// All recommended first as the order has an importance
|
|
105
|
+
...eslintConfigOverrides,
|
|
106
|
+
...commentsConfigOverrides,
|
|
107
|
+
...typescriptConfigOverrides,
|
|
108
|
+
...angularConfigOverrides,
|
|
109
|
+
...jsdocConfigOverrides,
|
|
110
|
+
...(getJestConfig('overrides')),
|
|
111
|
+
...preferArrowConfig,
|
|
112
|
+
...stylisticConfig,
|
|
113
|
+
...unicornConfig,
|
|
114
|
+
...importConfig,
|
|
115
|
+
...importNewlinesConfig,
|
|
116
|
+
// TODO: reactivate once https://github.com/nirtamir2/eslint-plugin-sort-export-all/issues/18 is fixed
|
|
117
|
+
// ...sortExportAll,
|
|
118
|
+
...unusedImportsConfig,
|
|
119
|
+
...otterConfig(o3r),
|
|
120
|
+
{
|
|
121
|
+
name: '@o3r/eslint-config/typescript/language-options',
|
|
122
|
+
files: [
|
|
123
|
+
'**/*.{c,m,}{t,j}s'
|
|
124
|
+
],
|
|
125
|
+
languageOptions: {
|
|
126
|
+
ecmaVersion: 2020,
|
|
127
|
+
sourceType: 'module',
|
|
128
|
+
parserOptions: {
|
|
129
|
+
ecmaFeatures: {
|
|
130
|
+
modules: true,
|
|
131
|
+
jsx: false
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
module.exports = configArray;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* Convert the rules set as `warn` to `error`
|
|
4
|
+
* @param {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config | import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} config config to process
|
|
5
|
+
* @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.Rules} only the upgraded rules
|
|
6
|
+
*/
|
|
7
|
+
function convertWarningsToErrors(config) {
|
|
8
|
+
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.Rules} */
|
|
9
|
+
const warningRulesUpgraded = {};
|
|
10
|
+
(Array.isArray(config) ? config : [config]).forEach(({ rules = {} }) => {
|
|
11
|
+
Object.entries(rules).forEach(([ruleName, ruleEntry]) => {
|
|
12
|
+
const severity = Array.isArray(ruleEntry) ? ruleEntry[0] : ruleEntry;
|
|
13
|
+
if (severity === 1 || severity === 'warn') {
|
|
14
|
+
warningRulesUpgraded[ruleName] = Array.isArray(ruleEntry) ? ['error', ...ruleEntry.slice(1)] : 'error';
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
return warningRulesUpgraded;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = { convertWarningsToErrors };
|