@croct/eslint-plugin 0.8.2 → 0.9.0
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/README.md +65 -29
- package/index.cjs +380324 -0
- package/index.d.cts +45 -0
- package/package.json +69 -50
- package/configs/cypress.js +0 -29
- package/configs/index.js +0 -12
- package/configs/javascript.js +0 -867
- package/configs/react.js +0 -355
- package/configs/typescript.js +0 -117
- package/index.js +0 -30
- package/rules/argument-spacing/index.js +0 -70
- package/rules/complex-expression-spacing/index.js +0 -66
- package/rules/createRule.js +0 -5
- package/rules/index.js +0 -17
- package/rules/jsx-attribute-spacing/index.js +0 -60
- package/rules/min-chained-call-depth/index.js +0 -158
- package/rules/newline-per-chained-call/index.js +0 -119
- package/rules/parameter-destructuring/index.js +0 -60
package/configs/react.js
DELETED
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createReactConfig = createReactConfig;
|
|
7
|
-
const eslint_plugin_react_1 = __importDefault(require("eslint-plugin-react"));
|
|
8
|
-
const eslint_plugin_react_hooks_1 = __importDefault(require("eslint-plugin-react-hooks"));
|
|
9
|
-
const eslint_plugin_testing_library_1 = __importDefault(require("eslint-plugin-testing-library"));
|
|
10
|
-
const eslint_plugin_jest_dom_1 = __importDefault(require("eslint-plugin-jest-dom"));
|
|
11
|
-
// @ts-expect-error - no types available
|
|
12
|
-
const eslint_plugin_jsx_a11y_1 = __importDefault(require("eslint-plugin-jsx-a11y"));
|
|
13
|
-
// @ts-expect-error - no types available
|
|
14
|
-
const eslint_plugin_1 = __importDefault(require("@stylistic/eslint-plugin"));
|
|
15
|
-
const baseRules = {
|
|
16
|
-
// Custom rule
|
|
17
|
-
'@croct/jsx-attribute-spacing': 'error',
|
|
18
|
-
// React rules (from airbnb, with customizations)
|
|
19
|
-
'react/display-name': 'off',
|
|
20
|
-
'react/forbid-prop-types': ['error', {
|
|
21
|
-
forbid: ['any', 'array', 'object'],
|
|
22
|
-
checkContextTypes: true,
|
|
23
|
-
checkChildContextTypes: true,
|
|
24
|
-
}],
|
|
25
|
-
'react/forbid-dom-props': ['off', { forbid: [] }],
|
|
26
|
-
'react/jsx-boolean-value': ['error', 'never', { always: [] }],
|
|
27
|
-
'react/jsx-closing-bracket-location': ['error', 'line-aligned'],
|
|
28
|
-
'react/jsx-closing-tag-location': 'error',
|
|
29
|
-
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
|
|
30
|
-
'react/jsx-handler-names': ['off', {
|
|
31
|
-
eventHandlerPrefix: 'handle',
|
|
32
|
-
eventHandlerPropPrefix: 'on',
|
|
33
|
-
}],
|
|
34
|
-
'react/jsx-indent-props': 'off',
|
|
35
|
-
'react/jsx-key': 'off',
|
|
36
|
-
'react/jsx-max-props-per-line': ['error', { maximum: 1, when: 'multiline' }],
|
|
37
|
-
'react/jsx-no-bind': [
|
|
38
|
-
'error',
|
|
39
|
-
{
|
|
40
|
-
allowArrowFunctions: true,
|
|
41
|
-
allowBind: false,
|
|
42
|
-
allowFunctions: true,
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
|
|
46
|
-
'react/jsx-no-literals': ['off', { noStrings: true }],
|
|
47
|
-
'react/jsx-no-undef': 'error',
|
|
48
|
-
'react/jsx-pascal-case': ['error', {
|
|
49
|
-
allowAllCaps: true,
|
|
50
|
-
ignore: [],
|
|
51
|
-
}],
|
|
52
|
-
'react/sort-prop-types': ['off', {
|
|
53
|
-
ignoreCase: true,
|
|
54
|
-
callbacksLast: false,
|
|
55
|
-
requiredFirst: false,
|
|
56
|
-
sortShapeProp: true,
|
|
57
|
-
}],
|
|
58
|
-
'react/jsx-sort-prop-types': 'off',
|
|
59
|
-
'react/jsx-sort-props': [
|
|
60
|
-
'error',
|
|
61
|
-
{
|
|
62
|
-
noSortAlphabetically: true,
|
|
63
|
-
multiline: 'last',
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
'react/jsx-sort-default-props': ['off', {
|
|
67
|
-
ignoreCase: true,
|
|
68
|
-
}],
|
|
69
|
-
'react/jsx-uses-react': 'off',
|
|
70
|
-
'react/jsx-uses-vars': 'error',
|
|
71
|
-
'react/no-danger': 'warn',
|
|
72
|
-
'react/no-deprecated': ['error'],
|
|
73
|
-
'react/no-did-mount-set-state': 'off',
|
|
74
|
-
'react/no-did-update-set-state': 'error',
|
|
75
|
-
'react/no-will-update-set-state': 'error',
|
|
76
|
-
'react/no-direct-mutation-state': 'off',
|
|
77
|
-
'react/no-is-mounted': 'error',
|
|
78
|
-
'react/no-multi-comp': 'off',
|
|
79
|
-
'react/no-set-state': 'off',
|
|
80
|
-
'react/no-string-refs': 'error',
|
|
81
|
-
'react/no-unknown-property': 'error',
|
|
82
|
-
'react/prefer-es6-class': ['error', 'always'],
|
|
83
|
-
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
|
|
84
|
-
'react/prop-types': 'off',
|
|
85
|
-
'react/react-in-jsx-scope': 'off',
|
|
86
|
-
'react/require-render-return': 'error',
|
|
87
|
-
'react/self-closing-comp': 'error',
|
|
88
|
-
'react/sort-comp': ['error', {
|
|
89
|
-
order: [
|
|
90
|
-
'static-variables',
|
|
91
|
-
'static-methods',
|
|
92
|
-
'instance-variables',
|
|
93
|
-
'lifecycle',
|
|
94
|
-
'/^handle.+$/',
|
|
95
|
-
'/^on.+$/',
|
|
96
|
-
'getters',
|
|
97
|
-
'setters',
|
|
98
|
-
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
|
|
99
|
-
'instance-methods',
|
|
100
|
-
'everything-else',
|
|
101
|
-
'rendering',
|
|
102
|
-
],
|
|
103
|
-
groups: {
|
|
104
|
-
lifecycle: [
|
|
105
|
-
'displayName',
|
|
106
|
-
'propTypes',
|
|
107
|
-
'contextTypes',
|
|
108
|
-
'childContextTypes',
|
|
109
|
-
'mixins',
|
|
110
|
-
'statics',
|
|
111
|
-
'defaultProps',
|
|
112
|
-
'constructor',
|
|
113
|
-
'getDefaultProps',
|
|
114
|
-
'getInitialState',
|
|
115
|
-
'state',
|
|
116
|
-
'getChildContext',
|
|
117
|
-
'getDerivedStateFromProps',
|
|
118
|
-
'componentWillMount',
|
|
119
|
-
'UNSAFE_componentWillMount',
|
|
120
|
-
'componentDidMount',
|
|
121
|
-
'componentWillReceiveProps',
|
|
122
|
-
'UNSAFE_componentWillReceiveProps',
|
|
123
|
-
'shouldComponentUpdate',
|
|
124
|
-
'componentWillUpdate',
|
|
125
|
-
'UNSAFE_componentWillUpdate',
|
|
126
|
-
'getSnapshotBeforeUpdate',
|
|
127
|
-
'componentDidUpdate',
|
|
128
|
-
'componentDidCatch',
|
|
129
|
-
'componentWillUnmount',
|
|
130
|
-
],
|
|
131
|
-
rendering: [
|
|
132
|
-
'/^render.+$/',
|
|
133
|
-
'render',
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
}],
|
|
137
|
-
'react/jsx-wrap-multilines': 'error',
|
|
138
|
-
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
|
|
139
|
-
'react/jsx-equals-spacing': ['error', 'never'],
|
|
140
|
-
'react/jsx-indent': ['error', 4],
|
|
141
|
-
'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }],
|
|
142
|
-
'react/jsx-filename-extension': [
|
|
143
|
-
1,
|
|
144
|
-
{
|
|
145
|
-
extensions: ['.tsx'],
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
'react/jsx-no-comment-textnodes': 'error',
|
|
149
|
-
'react/no-render-return-value': 'error',
|
|
150
|
-
'react/require-optimization': ['off', { allowDecorators: [] }],
|
|
151
|
-
'react/no-find-dom-node': 'error',
|
|
152
|
-
'react/forbid-component-props': ['off', { forbid: [] }],
|
|
153
|
-
'react/forbid-elements': ['off', { forbid: [] }],
|
|
154
|
-
'react/no-danger-with-children': 'error',
|
|
155
|
-
'react/no-unused-prop-types': ['error', {
|
|
156
|
-
customValidators: [],
|
|
157
|
-
skipShapeProps: true,
|
|
158
|
-
}],
|
|
159
|
-
'react/style-prop-object': 'error',
|
|
160
|
-
'react/no-unescaped-entities': 'error',
|
|
161
|
-
'react/no-children-prop': 'error',
|
|
162
|
-
'react/jsx-tag-spacing': ['error', {
|
|
163
|
-
closingSlash: 'never',
|
|
164
|
-
beforeSelfClosing: 'always',
|
|
165
|
-
afterOpening: 'never',
|
|
166
|
-
beforeClosing: 'never',
|
|
167
|
-
}],
|
|
168
|
-
'react/jsx-space-before-closing': ['off', 'always'],
|
|
169
|
-
'react/no-array-index-key': 'error',
|
|
170
|
-
'react/require-default-props': 'off',
|
|
171
|
-
'react/forbid-foreign-prop-types': ['warn', { allowInPropTypes: true }],
|
|
172
|
-
'react/void-dom-elements-no-children': 'error',
|
|
173
|
-
'react/default-props-match-prop-types': ['error', { allowRequiredDefaults: false }],
|
|
174
|
-
'react/no-redundant-should-component-update': 'error',
|
|
175
|
-
'react/no-unused-state': 'error',
|
|
176
|
-
'react/boolean-prop-naming': ['off', {
|
|
177
|
-
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
|
|
178
|
-
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
|
|
179
|
-
message: '',
|
|
180
|
-
}],
|
|
181
|
-
'react/no-typos': 'error',
|
|
182
|
-
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
|
|
183
|
-
'react/jsx-one-expression-per-line': 'off',
|
|
184
|
-
'react/destructuring-assignment': 'off',
|
|
185
|
-
'react/no-access-state-in-setstate': 'error',
|
|
186
|
-
'react/button-has-type': ['error', {
|
|
187
|
-
button: true,
|
|
188
|
-
submit: true,
|
|
189
|
-
reset: false,
|
|
190
|
-
}],
|
|
191
|
-
'react/jsx-child-element-spacing': 'off',
|
|
192
|
-
'react/no-this-in-sfc': 'error',
|
|
193
|
-
'react/jsx-max-depth': 'off',
|
|
194
|
-
'react/jsx-props-no-multi-spaces': 'error',
|
|
195
|
-
'react/no-unsafe': 'off',
|
|
196
|
-
'react/jsx-fragments': ['error', 'element'],
|
|
197
|
-
'react/jsx-curly-newline': ['error', {
|
|
198
|
-
multiline: 'consistent',
|
|
199
|
-
singleline: 'consistent',
|
|
200
|
-
}],
|
|
201
|
-
'react/state-in-constructor': ['error', 'always'],
|
|
202
|
-
'react/static-property-placement': ['error', 'property assignment'],
|
|
203
|
-
'react/jsx-props-no-spreading': 'off',
|
|
204
|
-
'react/prefer-read-only-props': 'off',
|
|
205
|
-
'react/jsx-no-script-url': ['error', [
|
|
206
|
-
{
|
|
207
|
-
name: 'Link',
|
|
208
|
-
props: ['to'],
|
|
209
|
-
},
|
|
210
|
-
]],
|
|
211
|
-
'react/jsx-no-useless-fragment': [
|
|
212
|
-
'error',
|
|
213
|
-
{
|
|
214
|
-
allowExpressions: true,
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
'react/no-adjacent-inline-elements': 'off',
|
|
218
|
-
'react/function-component-definition': 'off',
|
|
219
|
-
'react/jsx-newline': [
|
|
220
|
-
'error',
|
|
221
|
-
{
|
|
222
|
-
prevent: true,
|
|
223
|
-
},
|
|
224
|
-
],
|
|
225
|
-
'react/jsx-no-constructed-context-values': 'error',
|
|
226
|
-
'react/no-unstable-nested-components': [
|
|
227
|
-
'error',
|
|
228
|
-
{
|
|
229
|
-
allowAsProps: true,
|
|
230
|
-
},
|
|
231
|
-
],
|
|
232
|
-
'react/no-namespace': 'error',
|
|
233
|
-
'react/prefer-exact-props': 'error',
|
|
234
|
-
'react/no-arrow-function-lifecycle': 'error',
|
|
235
|
-
'react/no-invalid-html-attribute': 'error',
|
|
236
|
-
'react/no-unused-class-component-methods': 'error',
|
|
237
|
-
// React Hooks rules
|
|
238
|
-
'react-hooks/rules-of-hooks': 'error',
|
|
239
|
-
'react-hooks/exhaustive-deps': 'warn',
|
|
240
|
-
// Testing Library rules (overrides)
|
|
241
|
-
'testing-library/no-container': 'off',
|
|
242
|
-
'testing-library/no-node-access': 'off',
|
|
243
|
-
'testing-library/await-async-utils': 'off',
|
|
244
|
-
// JSX A11y rules (overrides)
|
|
245
|
-
'jsx-a11y/aria-role': [
|
|
246
|
-
'error',
|
|
247
|
-
{
|
|
248
|
-
ignoreNonDOM: true,
|
|
249
|
-
},
|
|
250
|
-
],
|
|
251
|
-
// Underscore dangle override for Redux DevTools
|
|
252
|
-
'no-underscore-dangle': ['error', {
|
|
253
|
-
allow: ['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'],
|
|
254
|
-
allowAfterThis: false,
|
|
255
|
-
allowAfterSuper: false,
|
|
256
|
-
enforceInMethodNames: true,
|
|
257
|
-
}],
|
|
258
|
-
// Class methods use this override for React lifecycle methods
|
|
259
|
-
'class-methods-use-this': ['error', {
|
|
260
|
-
exceptMethods: [
|
|
261
|
-
'render',
|
|
262
|
-
'getInitialState',
|
|
263
|
-
'getDefaultProps',
|
|
264
|
-
'getChildContext',
|
|
265
|
-
'componentWillMount',
|
|
266
|
-
'UNSAFE_componentWillMount',
|
|
267
|
-
'componentDidMount',
|
|
268
|
-
'componentWillReceiveProps',
|
|
269
|
-
'UNSAFE_componentWillReceiveProps',
|
|
270
|
-
'shouldComponentUpdate',
|
|
271
|
-
'componentWillUpdate',
|
|
272
|
-
'UNSAFE_componentWillUpdate',
|
|
273
|
-
'componentDidUpdate',
|
|
274
|
-
'componentWillUnmount',
|
|
275
|
-
'componentDidCatch',
|
|
276
|
-
'getSnapshotBeforeUpdate',
|
|
277
|
-
],
|
|
278
|
-
}],
|
|
279
|
-
// Import restrictions
|
|
280
|
-
'no-restricted-imports': [
|
|
281
|
-
'error',
|
|
282
|
-
{
|
|
283
|
-
name: 'react',
|
|
284
|
-
importNames: ['default'],
|
|
285
|
-
message: 'The React runtime is automatically imported, '
|
|
286
|
-
+ 'you can simply omit the import declaration in this case.',
|
|
287
|
-
},
|
|
288
|
-
],
|
|
289
|
-
// Import order for React (using import-x)
|
|
290
|
-
'import-x/order': [
|
|
291
|
-
'error',
|
|
292
|
-
{
|
|
293
|
-
groups: [
|
|
294
|
-
'builtin',
|
|
295
|
-
'external',
|
|
296
|
-
'internal',
|
|
297
|
-
],
|
|
298
|
-
pathGroups: [
|
|
299
|
-
{
|
|
300
|
-
pattern: 'react',
|
|
301
|
-
group: 'external',
|
|
302
|
-
position: 'before',
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
pathGroupsExcludedImportTypes: ['react'],
|
|
306
|
-
'newlines-between': 'never',
|
|
307
|
-
alphabetize: {
|
|
308
|
-
order: 'asc',
|
|
309
|
-
caseInsensitive: true,
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
};
|
|
314
|
-
// Factory function to create React config with the plugin reference
|
|
315
|
-
function createReactConfig(plugin, javascriptConfig) {
|
|
316
|
-
return [
|
|
317
|
-
...javascriptConfig,
|
|
318
|
-
eslint_plugin_react_1.default.configs.flat.recommended,
|
|
319
|
-
eslint_plugin_testing_library_1.default.configs['flat/react'],
|
|
320
|
-
eslint_plugin_jest_dom_1.default.configs['flat/recommended'],
|
|
321
|
-
eslint_plugin_jsx_a11y_1.default.flatConfigs.recommended,
|
|
322
|
-
{
|
|
323
|
-
name: '@croct/react',
|
|
324
|
-
plugins: {
|
|
325
|
-
'react-hooks': eslint_plugin_react_hooks_1.default,
|
|
326
|
-
'@stylistic': eslint_plugin_1.default,
|
|
327
|
-
'@croct': plugin,
|
|
328
|
-
},
|
|
329
|
-
languageOptions: {
|
|
330
|
-
parserOptions: {
|
|
331
|
-
ecmaFeatures: {
|
|
332
|
-
jsx: true,
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
settings: {
|
|
337
|
-
'import-x/resolver': {
|
|
338
|
-
node: {
|
|
339
|
-
extensions: ['.js', '.jsx', '.json'],
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
react: {
|
|
343
|
-
pragma: 'React',
|
|
344
|
-
version: 'detect',
|
|
345
|
-
},
|
|
346
|
-
propWrapperFunctions: [
|
|
347
|
-
'forbidExtraProps',
|
|
348
|
-
'exact',
|
|
349
|
-
'Object.freeze',
|
|
350
|
-
],
|
|
351
|
-
},
|
|
352
|
-
rules: baseRules,
|
|
353
|
-
},
|
|
354
|
-
];
|
|
355
|
-
}
|
package/configs/typescript.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createTypescriptConfig = createTypescriptConfig;
|
|
7
|
-
const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
|
|
8
|
-
const parser_1 = __importDefault(require("@typescript-eslint/parser"));
|
|
9
|
-
const eslint_plugin_jest_1 = __importDefault(require("eslint-plugin-jest"));
|
|
10
|
-
// @ts-expect-error - no types available
|
|
11
|
-
const eslint_plugin_1 = __importDefault(require("@stylistic/eslint-plugin"));
|
|
12
|
-
const baseRules = {
|
|
13
|
-
'import-x/export': 'off',
|
|
14
|
-
'@typescript-eslint/array-type': ['error', {
|
|
15
|
-
default: 'array-simple',
|
|
16
|
-
}],
|
|
17
|
-
'@typescript-eslint/prefer-as-const': 'error',
|
|
18
|
-
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
19
|
-
'@stylistic/type-annotation-spacing': 'error',
|
|
20
|
-
'@stylistic/semi': ['error', 'always'],
|
|
21
|
-
'@typescript-eslint/strict-boolean-expressions': ['error', {
|
|
22
|
-
allowString: false,
|
|
23
|
-
allowNumber: false,
|
|
24
|
-
allowNullableObject: false,
|
|
25
|
-
}],
|
|
26
|
-
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
27
|
-
'no-shadow': 'off',
|
|
28
|
-
'@typescript-eslint/no-shadow': ['error', {
|
|
29
|
-
ignoreTypeValueShadow: true,
|
|
30
|
-
ignoreFunctionTypeParameterNameValueShadow: true,
|
|
31
|
-
}],
|
|
32
|
-
'@typescript-eslint/explicit-member-accessibility': [
|
|
33
|
-
'error',
|
|
34
|
-
],
|
|
35
|
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
36
|
-
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
|
|
37
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
38
|
-
'no-use-before-define': 'off',
|
|
39
|
-
'@typescript-eslint/no-use-before-define': 'off',
|
|
40
|
-
'no-unused-expressions': 'off',
|
|
41
|
-
'@typescript-eslint/no-unused-expressions': 'error',
|
|
42
|
-
'@stylistic/indent': ['error', 4, {
|
|
43
|
-
SwitchCase: 1,
|
|
44
|
-
}],
|
|
45
|
-
'@typescript-eslint/no-unused-vars': [
|
|
46
|
-
'error',
|
|
47
|
-
{
|
|
48
|
-
args: 'after-used',
|
|
49
|
-
ignoreRestSiblings: true,
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
'no-unused-vars': 'off',
|
|
53
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
54
|
-
'@stylistic/object-curly-spacing': 'error',
|
|
55
|
-
'@stylistic/member-delimiter-style': ['error', {
|
|
56
|
-
multiline: {
|
|
57
|
-
delimiter: 'comma',
|
|
58
|
-
requireLast: true,
|
|
59
|
-
},
|
|
60
|
-
singleline: {
|
|
61
|
-
delimiter: 'comma',
|
|
62
|
-
requireLast: false,
|
|
63
|
-
},
|
|
64
|
-
overrides: {
|
|
65
|
-
interface: {
|
|
66
|
-
singleline: {
|
|
67
|
-
delimiter: 'semi',
|
|
68
|
-
},
|
|
69
|
-
multiline: {
|
|
70
|
-
delimiter: 'semi',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
}],
|
|
75
|
-
'no-undef': 'off',
|
|
76
|
-
'@typescript-eslint/no-namespace': 'off',
|
|
77
|
-
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
78
|
-
// Disable rules that turn `any` into `unknown`, places where `unknown` is the preferred type
|
|
79
|
-
// have that type already.
|
|
80
|
-
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
81
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
82
|
-
'@typescript-eslint/no-unsafe-call': 'off',
|
|
83
|
-
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
|
|
84
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
85
|
-
'@typescript-eslint/no-unsafe-return': 'off',
|
|
86
|
-
'@typescript-eslint/no-unsafe-unary-minus': 'off',
|
|
87
|
-
// Breaks with overloaded functions that implement both callback and Promise signatures
|
|
88
|
-
'@typescript-eslint/no-misused-promises': 'off',
|
|
89
|
-
// Doesn't detect classes that implement `toString` method
|
|
90
|
-
'@typescript-eslint/no-base-to-string': 'off',
|
|
91
|
-
// Conflict with TS promise ignore explicitly (void Promise)
|
|
92
|
-
'no-void': 'off',
|
|
93
|
-
};
|
|
94
|
-
// Factory function to create TypeScript config with the plugin reference
|
|
95
|
-
function createTypescriptConfig(plugin, javascriptConfig) {
|
|
96
|
-
return [
|
|
97
|
-
...javascriptConfig,
|
|
98
|
-
...typescript_eslint_1.default.configs.recommendedTypeChecked,
|
|
99
|
-
eslint_plugin_jest_1.default.configs['flat/recommended'],
|
|
100
|
-
{
|
|
101
|
-
name: '@croct/typescript',
|
|
102
|
-
files: ['**/*.ts', '**/*.tsx'],
|
|
103
|
-
plugins: {
|
|
104
|
-
'@stylistic': eslint_plugin_1.default,
|
|
105
|
-
'@croct': plugin,
|
|
106
|
-
},
|
|
107
|
-
languageOptions: {
|
|
108
|
-
parser: parser_1.default,
|
|
109
|
-
parserOptions: {
|
|
110
|
-
// Enable type-aware linting
|
|
111
|
-
projectService: true,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
rules: baseRules,
|
|
115
|
-
},
|
|
116
|
-
];
|
|
117
|
-
}
|
package/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rules = exports.configs = void 0;
|
|
4
|
-
const rules_1 = require("./rules");
|
|
5
|
-
Object.defineProperty(exports, "rules", { enumerable: true, get: function () { return rules_1.rules; } });
|
|
6
|
-
const javascript_1 = require("./configs/javascript");
|
|
7
|
-
const typescript_1 = require("./configs/typescript");
|
|
8
|
-
const react_1 = require("./configs/react");
|
|
9
|
-
const cypress_1 = require("./configs/cypress");
|
|
10
|
-
// Create the plugin with just the rules first
|
|
11
|
-
const plugin = {
|
|
12
|
-
// Cast from TypeScript Rule Module to ESLint RuleDefinition.
|
|
13
|
-
// Due to variance, TS can't verify the type directly.
|
|
14
|
-
rules: rules_1.rules,
|
|
15
|
-
configs: {},
|
|
16
|
-
};
|
|
17
|
-
// Create configs with the plugin reference
|
|
18
|
-
const javascriptConfig = (0, javascript_1.createJavaScriptConfig)(plugin);
|
|
19
|
-
const typescriptConfig = (0, typescript_1.createTypescriptConfig)(plugin, javascriptConfig);
|
|
20
|
-
const reactConfig = (0, react_1.createReactConfig)(plugin, javascriptConfig);
|
|
21
|
-
const cypressConfig = (0, cypress_1.createCypressConfig)(plugin, javascriptConfig);
|
|
22
|
-
exports.configs = {
|
|
23
|
-
javascript: javascriptConfig,
|
|
24
|
-
typescript: typescriptConfig,
|
|
25
|
-
react: reactConfig,
|
|
26
|
-
cypress: cypressConfig,
|
|
27
|
-
};
|
|
28
|
-
Object.assign(plugin.configs, exports.configs);
|
|
29
|
-
// Export the plugin as default
|
|
30
|
-
exports.default = plugin;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.argumentSpacing = void 0;
|
|
4
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
-
const createRule_1 = require("../createRule");
|
|
6
|
-
exports.argumentSpacing = (0, createRule_1.createRule)({
|
|
7
|
-
name: 'argument-spacing',
|
|
8
|
-
meta: {
|
|
9
|
-
type: 'suggestion',
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Enforces a surrounding line break before and after '
|
|
12
|
-
+ 'the argument list in multiline functional calls.',
|
|
13
|
-
},
|
|
14
|
-
fixable: 'whitespace',
|
|
15
|
-
schema: [],
|
|
16
|
-
messages: {
|
|
17
|
-
missing: 'Missing new line.',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
defaultOptions: [],
|
|
21
|
-
create: context => {
|
|
22
|
-
function check(node) {
|
|
23
|
-
const sourceCode = context.getSourceCode();
|
|
24
|
-
if (node.arguments.length === 0) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const lastArgument = node.arguments[node.arguments.length - 1];
|
|
28
|
-
const firstToken = sourceCode.getTokenBefore(node.arguments[0], {
|
|
29
|
-
filter: token => token.value === '(',
|
|
30
|
-
});
|
|
31
|
-
const lastToken = sourceCode.getTokenAfter(lastArgument, {
|
|
32
|
-
filter: token => token.value === ')',
|
|
33
|
-
});
|
|
34
|
-
if (firstToken.loc.start.line === lastToken.loc.end.line) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const lastArgumentFirstToken = sourceCode.getFirstToken(lastArgument);
|
|
38
|
-
if ((lastArgument.type !== utils_1.TSESTree.AST_NODE_TYPES.ArrowFunctionExpression
|
|
39
|
-
|| lastArgument.body.type === utils_1.TSESTree.AST_NODE_TYPES.BlockStatement)
|
|
40
|
-
&& firstToken.loc.start.line === lastArgumentFirstToken.loc.start.line) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const tokens = [
|
|
44
|
-
firstToken,
|
|
45
|
-
...node.arguments,
|
|
46
|
-
lastToken,
|
|
47
|
-
];
|
|
48
|
-
for (let i = 1; i < tokens.length; i++) {
|
|
49
|
-
const previousToken = tokens[i - 1];
|
|
50
|
-
const currentToken = tokens[i];
|
|
51
|
-
if (previousToken.loc.end.line === currentToken.loc.start.line) {
|
|
52
|
-
const tokenBefore = sourceCode.getTokenBefore(currentToken, { includeComments: true });
|
|
53
|
-
context.report({
|
|
54
|
-
node: node,
|
|
55
|
-
loc: {
|
|
56
|
-
start: tokenBefore.loc.end,
|
|
57
|
-
end: currentToken.loc.start,
|
|
58
|
-
},
|
|
59
|
-
messageId: 'missing',
|
|
60
|
-
fix: fixer => fixer.replaceTextRange([tokenBefore.range[1], currentToken.range[0]], '\n'),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
CallExpression: check,
|
|
67
|
-
NewExpression: check,
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.complexExpressionSpacing = void 0;
|
|
4
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
-
const createRule_1 = require("../createRule");
|
|
6
|
-
exports.complexExpressionSpacing = (0, createRule_1.createRule)({
|
|
7
|
-
name: 'complex-expression-spacing',
|
|
8
|
-
meta: {
|
|
9
|
-
type: 'suggestion',
|
|
10
|
-
docs: {
|
|
11
|
-
description: 'Enforces a surrounding line break in complex expression.',
|
|
12
|
-
},
|
|
13
|
-
fixable: 'whitespace',
|
|
14
|
-
schema: [],
|
|
15
|
-
messages: {
|
|
16
|
-
missing: 'Missing new line.',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
defaultOptions: [],
|
|
20
|
-
create: context => {
|
|
21
|
-
const sourceCode = context.getSourceCode();
|
|
22
|
-
function check(node) {
|
|
23
|
-
const parentPreviousToken = sourceCode.getTokenBefore(node, {
|
|
24
|
-
filter: token => token.type === utils_1.TSESTree.AST_TOKEN_TYPES.Punctuator,
|
|
25
|
-
});
|
|
26
|
-
const parentNextToken = sourceCode.getTokenAfter(node, {
|
|
27
|
-
filter: token => token.type === utils_1.TSESTree.AST_TOKEN_TYPES.Punctuator,
|
|
28
|
-
});
|
|
29
|
-
if (parentPreviousToken.loc.end.line === parentNextToken.loc.start.line) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const firstToken = sourceCode.getFirstToken(node);
|
|
33
|
-
const lastToken = sourceCode.getLastToken(node);
|
|
34
|
-
const tokens = [
|
|
35
|
-
[parentPreviousToken, firstToken],
|
|
36
|
-
[lastToken, parentNextToken],
|
|
37
|
-
];
|
|
38
|
-
for (const [previousToken, currentToken] of tokens) {
|
|
39
|
-
if (previousToken.loc.end.line !== currentToken.loc.start.line) {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const tokenBefore = sourceCode.getTokenBefore(currentToken, { includeComments: true });
|
|
43
|
-
context.report({
|
|
44
|
-
node: node,
|
|
45
|
-
loc: {
|
|
46
|
-
start: tokenBefore.loc.end,
|
|
47
|
-
end: currentToken.loc.start,
|
|
48
|
-
},
|
|
49
|
-
messageId: 'missing',
|
|
50
|
-
fix: fixer => fixer.replaceTextRange([tokenBefore.range[1], currentToken.range[0]], '\n'),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
ArrowFunctionExpression: (node) => {
|
|
56
|
-
const { body } = node;
|
|
57
|
-
if (body.type === utils_1.TSESTree.AST_NODE_TYPES.ConditionalExpression) {
|
|
58
|
-
check(body);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
IfStatement: (node) => {
|
|
62
|
-
check(node.test);
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
});
|
package/rules/createRule.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRule = void 0;
|
|
4
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
-
exports.createRule = utils_1.ESLintUtils.RuleCreator(name => `https://github.com/croct-tech/coding-standard-js/tree/master/docs/${name}.md`);
|
package/rules/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rules = void 0;
|
|
4
|
-
const argument_spacing_1 = require("./argument-spacing");
|
|
5
|
-
const jsx_attribute_spacing_1 = require("./jsx-attribute-spacing");
|
|
6
|
-
const complex_expression_spacing_1 = require("./complex-expression-spacing");
|
|
7
|
-
const newline_per_chained_call_1 = require("./newline-per-chained-call");
|
|
8
|
-
const min_chained_call_depth_1 = require("./min-chained-call-depth");
|
|
9
|
-
const parameter_destructuring_1 = require("./parameter-destructuring");
|
|
10
|
-
exports.rules = {
|
|
11
|
-
'argument-spacing': argument_spacing_1.argumentSpacing,
|
|
12
|
-
'jsx-attribute-spacing': jsx_attribute_spacing_1.jsxAttributeSpacing,
|
|
13
|
-
'complex-expression-spacing': complex_expression_spacing_1.complexExpressionSpacing,
|
|
14
|
-
'newline-per-chained-call': newline_per_chained_call_1.newlinePerChainedCall,
|
|
15
|
-
'min-chained-call-depth': min_chained_call_depth_1.minChainedCallDepth,
|
|
16
|
-
'parameter-destructuring': parameter_destructuring_1.parameterDestructuring,
|
|
17
|
-
};
|