@oriflame/config-eslint 4.3.0 → 5.0.3
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 +1 -1
- package/README.md +2 -81
- package/dts/index.d.ts +10 -0
- package/lib/index.js +45 -40
- package/lib/index.js.map +1 -0
- package/package.json +37 -30
- package/src/index.ts +21 -27
- package/CHANGELOG.md +0 -3617
- package/lib/index.d.ts +0 -10
- package/lib/index.d.ts.map +0 -1
- package/lib/presets/SECRET_CONFIG_DO_NOT_USE_THIS.d.ts +0 -4
- package/lib/presets/SECRET_CONFIG_DO_NOT_USE_THIS.d.ts.map +0 -1
- package/lib/presets/SECRET_CONFIG_DO_NOT_USE_THIS.js +0 -32
- package/lib/presets/base.d.ts +0 -4
- package/lib/presets/base.d.ts.map +0 -1
- package/lib/presets/base.js +0 -120
- package/lib/presets/future.d.ts +0 -4
- package/lib/presets/future.d.ts.map +0 -1
- package/lib/presets/future.js +0 -13
- package/lib/presets/nextjs.d.ts +0 -4
- package/lib/presets/nextjs.d.ts.map +0 -1
- package/lib/presets/nextjs.js +0 -13
- package/lib/presets/node.d.ts +0 -4
- package/lib/presets/node.d.ts.map +0 -1
- package/lib/presets/node.js +0 -26
- package/lib/presets/prettier.d.ts +0 -4
- package/lib/presets/prettier.d.ts.map +0 -1
- package/lib/presets/prettier.js +0 -13
- package/lib/presets/typescript.d.ts +0 -4
- package/lib/presets/typescript.d.ts.map +0 -1
- package/lib/presets/typescript.js +0 -40
- package/lib/resolvers/graphql.d.ts +0 -6
- package/lib/resolvers/graphql.d.ts.map +0 -1
- package/lib/resolvers/graphql.js +0 -12
- package/lib/rules/a11y.d.ts +0 -4
- package/lib/rules/a11y.d.ts.map +0 -1
- package/lib/rules/a11y.js +0 -45
- package/lib/rules/eslint-comments.d.ts +0 -4
- package/lib/rules/eslint-comments.d.ts.map +0 -1
- package/lib/rules/eslint-comments.js +0 -14
- package/lib/rules/eslint.d.ts +0 -4
- package/lib/rules/eslint.d.ts.map +0 -1
- package/lib/rules/eslint.js +0 -385
- package/lib/rules/import.d.ts +0 -4
- package/lib/rules/import.d.ts.map +0 -1
- package/lib/rules/import.js +0 -76
- package/lib/rules/jest.d.ts +0 -4
- package/lib/rules/jest.d.ts.map +0 -1
- package/lib/rules/jest.js +0 -59
- package/lib/rules/nextjs.d.ts +0 -4
- package/lib/rules/nextjs.d.ts.map +0 -1
- package/lib/rules/nextjs.js +0 -17
- package/lib/rules/node.d.ts +0 -4
- package/lib/rules/node.d.ts.map +0 -1
- package/lib/rules/node.js +0 -45
- package/lib/rules/prettier.d.ts +0 -4
- package/lib/rules/prettier.d.ts.map +0 -1
- package/lib/rules/prettier.js +0 -6
- package/lib/rules/promise.d.ts +0 -4
- package/lib/rules/promise.d.ts.map +0 -1
- package/lib/rules/promise.js +0 -24
- package/lib/rules/react-hooks.d.ts +0 -4
- package/lib/rules/react-hooks.d.ts.map +0 -1
- package/lib/rules/react-hooks.js +0 -7
- package/lib/rules/react.d.ts +0 -4
- package/lib/rules/react.d.ts.map +0 -1
- package/lib/rules/react.js +0 -143
- package/lib/rules/testing-library.d.ts +0 -4
- package/lib/rules/testing-library.d.ts.map +0 -1
- package/lib/rules/testing-library.js +0 -31
- package/lib/rules/typescript.d.ts +0 -4
- package/lib/rules/typescript.d.ts.map +0 -1
- package/lib/rules/typescript.js +0 -369
- package/lib/rules/unicorn.d.ts +0 -4
- package/lib/rules/unicorn.d.ts.map +0 -1
- package/lib/rules/unicorn.js +0 -105
- package/src/presets/SECRET_CONFIG_DO_NOT_USE_THIS.ts +0 -34
- package/src/presets/base.ts +0 -143
- package/src/presets/future.ts +0 -13
- package/src/presets/nextjs.ts +0 -13
- package/src/presets/node.ts +0 -27
- package/src/presets/prettier.ts +0 -13
- package/src/presets/typescript.ts +0 -45
- package/src/resolvers/graphql.ts +0 -11
- package/src/rules/a11y.ts +0 -47
- package/src/rules/eslint-comments.ts +0 -16
- package/src/rules/eslint.ts +0 -384
- package/src/rules/import.ts +0 -79
- package/src/rules/jest.ts +0 -64
- package/src/rules/nextjs.ts +0 -19
- package/src/rules/node.ts +0 -47
- package/src/rules/prettier.ts +0 -8
- package/src/rules/promise.ts +0 -26
- package/src/rules/react-hooks.ts +0 -9
- package/src/rules/react.ts +0 -145
- package/src/rules/testing-library.ts +0 -33
- package/src/rules/typescript.ts +0 -377
- package/src/rules/unicorn.ts +0 -108
- package/test/index.test.ts +0 -81
- package/test/lint-files/combo.ts +0 -10
- package/test/lint-files/errors/combo.ts +0 -3
- package/test/lint-files/errors/javascript.js +0 -2
- package/test/lint-files/errors/next.js +0 -11
- package/test/lint-files/errors/node.js +0 -3
- package/test/lint-files/errors/prettier.js +0 -5
- package/test/lint-files/errors/test.js +0 -3
- package/test/lint-files/errors/typescript.ts +0 -3
- package/test/lint-files/javascript.js +0 -1
- package/test/lint-files/next.js +0 -5
- package/test/lint-files/node.js +0 -2
- package/test/lint-files/prettier.js +0 -1
- package/test/lint-files/test.js +0 -5
- package/test/lint-files/typescript.ts +0 -20
- package/test/tsconfig.json +0 -19
- package/test/utils/getErrors.ts +0 -16
- package/tools/check-rules/allRules.ts +0 -99
- package/tools/check-rules/index.ts +0 -90
- package/tools/check-rules/tsconfig.json +0 -17
- package/tsconfig.json +0 -22
- package/tsconfig.tsbuildinfo +0 -1
package/src/rules/unicorn.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { ESLintConfig } from '@beemo/driver-eslint';
|
|
2
|
-
|
|
3
|
-
const config: ESLintConfig['rules'] = {
|
|
4
|
-
// override ESLint rules
|
|
5
|
-
'no-nested-ternary': 'off', // disallow nested ternary expressions
|
|
6
|
-
'no-warning-comments': 'off', // disallow specified warning terms in comments
|
|
7
|
-
|
|
8
|
-
// eslint-plugin-unicorn rules
|
|
9
|
-
'unicorn/better-regex': 'warn', // improve regexes by making them shorter, consistent, and safer
|
|
10
|
-
'unicorn/catch-error-name': 'warn', // enforce a specific parameter name in catch clauses
|
|
11
|
-
'unicorn/consistent-destructuring': 'error', // use destructured variables over properties.
|
|
12
|
-
'unicorn/consistent-function-scoping': 'error', // move function definitions to the highest possible scope
|
|
13
|
-
'unicorn/custom-error-definition': 'error', // enforce correct Error subclassing
|
|
14
|
-
'unicorn/empty-brace-spaces': 'off', // enforce no spaces between braces
|
|
15
|
-
'unicorn/error-message': 'error', // enforce passing a message value when throwing a built-in error
|
|
16
|
-
'unicorn/escape-case': 'warn', // require escape sequences to use uppercase values
|
|
17
|
-
'unicorn/expiring-todo-comments': [
|
|
18
|
-
'warn',
|
|
19
|
-
{
|
|
20
|
-
terms: ['todo:', 'fixme:', 'debug:'],
|
|
21
|
-
},
|
|
22
|
-
], // add expiration conditions to to do comments
|
|
23
|
-
'unicorn/explicit-length-check': 'off', // enforce explicitly comparing the length property of a value
|
|
24
|
-
'unicorn/filename-case': 'off', // enforce a case style for filenames
|
|
25
|
-
'unicorn/import-index': 'error', // enforce importing index files with .
|
|
26
|
-
'unicorn/import-style': 'warn', // enforce specific import styles per module
|
|
27
|
-
'unicorn/new-for-builtins': 'warn', // enforce the use of new for all builtins, except String, Number, Boolean, Symbol and BigInt
|
|
28
|
-
'unicorn/no-abusive-eslint-disable': 'off', // enforce specifying rules to disable in eslint-disable comments
|
|
29
|
-
'unicorn/no-array-callback-reference': 'off', // prevent passing a function reference directly to iterator methods
|
|
30
|
-
'unicorn/no-array-for-each': 'off', // prefer for…of over Array#forEach(…)
|
|
31
|
-
'unicorn/no-array-method-this-argument': 'error', // disallow using the this argument in array methods
|
|
32
|
-
'unicorn/no-array-push-push': 'error', // enforce combining multiple Array#push() into one call
|
|
33
|
-
'unicorn/no-array-reduce': 'off', // disallow Array#reduce() and Array#reduceRight()
|
|
34
|
-
'unicorn/no-console-spaces': 'off', // do not use leading/trailing space between console.log parameters
|
|
35
|
-
'unicorn/no-document-cookie': 'error', // do not use document.cookie directly
|
|
36
|
-
'unicorn/no-for-loop': 'warn', // Do not use a for loop that can be replaced with a for-of loop
|
|
37
|
-
'unicorn/no-hex-escape': 'warn', // enforce the use of Unicode escapes instead of hexadecimal escapes
|
|
38
|
-
'unicorn/no-instanceof-array': 'error', // require Array.isArray() instead of instanceof Array
|
|
39
|
-
'unicorn/no-keyword-prefix': 'off', // disallow identifiers starting with new or class
|
|
40
|
-
'unicorn/no-lonely-if': 'warn', // disallow if statements as the only statement in if blocks without else
|
|
41
|
-
'unicorn/no-nested-ternary': 'error', // disallow nested ternary expressions
|
|
42
|
-
'unicorn/no-new-array': 'error', // disallow new Array()
|
|
43
|
-
'unicorn/no-new-buffer': 'error', // enforce the use of Buffer.from() and Buffer.alloc() instead of the deprecated new Buffer()
|
|
44
|
-
'unicorn/no-null': 'off', // disallow the use of the null literal
|
|
45
|
-
'unicorn/no-object-as-default-parameter': 'error', // disallow the use of objects as default parameters
|
|
46
|
-
'unicorn/no-process-exit': 'off', // disallow process.exit()
|
|
47
|
-
'unicorn/no-static-only-class': 'error', // forbid classes that only have static members
|
|
48
|
-
'unicorn/no-this-assignment': 'off', // disallow assigning this to a variable
|
|
49
|
-
'unicorn/no-unreadable-array-destructuring': 'warn', // disallow unreadable array destructuring
|
|
50
|
-
'unicorn/no-unsafe-regex': 'off', // disallow unsafe regular expressions
|
|
51
|
-
'unicorn/no-unused-properties': 'off', // disallow unused object properties
|
|
52
|
-
'unicorn/no-useless-length-check': 'off', // disallow useless array length check
|
|
53
|
-
'unicorn/no-useless-spread': 'error', // disallow unnecessary spread
|
|
54
|
-
'unicorn/no-useless-undefined': 'off', // disallow useless undefined
|
|
55
|
-
'unicorn/no-zero-fractions': 'error', // disallow number literals with zero fractions or dangling dots
|
|
56
|
-
'unicorn/number-literal-case': 'error', // enforce lowercase identifier and uppercase value for number literals
|
|
57
|
-
'unicorn/numeric-separators-style': 'off', // enforce the style of numeric separators by correctly grouping digits
|
|
58
|
-
'unicorn/prefer-add-event-listener': 'error', // prefer .addEventListener() and .removeEventListener() over on-functions
|
|
59
|
-
'unicorn/prefer-array-find': 'warn', // prefer .find(…) over the first element from .filter(…)
|
|
60
|
-
'unicorn/prefer-array-flat': 'warn', // prefer Array#flat() over legacy techniques to flatten arrays
|
|
61
|
-
'unicorn/prefer-array-flat-map': 'warn', // prefer .flatMap(…) over .map(…).flat()
|
|
62
|
-
'unicorn/prefer-array-index-of': 'warn', // prefer Array#indexOf() over Array#findIndex() when looking for the index of an item
|
|
63
|
-
'unicorn/prefer-array-some': 'warn', // prefer .some(…) over .find(…)
|
|
64
|
-
'unicorn/prefer-at': 'warn', // prefer .at() method for index access and String#charAt()
|
|
65
|
-
'unicorn/prefer-date-now': 'warn', // prefer Date.now() to get the number of milliseconds since the Unix Epoch
|
|
66
|
-
'unicorn/prefer-default-parameters': 'error', // prefer default parameters over reassignment
|
|
67
|
-
'unicorn/prefer-dom-node-append': 'warn', // prefer Node#append() over Node#appendChild()
|
|
68
|
-
'unicorn/prefer-dom-node-dataset': 'warn', // prefer using .dataset on DOM elements over .setAttribute(…)
|
|
69
|
-
'unicorn/prefer-dom-node-remove': 'warn', // prefer childNode.remove() over parentNode.removeChild(childNode)
|
|
70
|
-
'unicorn/prefer-dom-node-text-content': 'warn', // prefer .textContent over .innerText
|
|
71
|
-
'unicorn/prefer-includes': 'off', // prefer .includes() over .indexOf() when checking for existence or non-existence
|
|
72
|
-
'unicorn/prefer-keyboard-event-key': 'warn', // prefer KeyboardEvent#key over KeyboardEvent#keyCode.
|
|
73
|
-
'unicorn/prefer-math-trunc': 'warn', // enforce the use of Math.trunc instead of bitwise operators
|
|
74
|
-
'unicorn/prefer-modern-dom-apis': 'warn', // prefer .before() over .insertBefore(), .replaceWith() over .replaceChild(), prefer one of .before(), .after(), .append() or .prepend() over insertAdjacentText() and insertAdjacentElement()
|
|
75
|
-
// FIXME [@rajzik]: This is good rule but adoption isn't great so far
|
|
76
|
-
'unicorn/prefer-module': 'off', // Prefer JavaScript modules (ESM) over CommonJS
|
|
77
|
-
// FIXME [eslint-plugin-import]: Once https://github.com/benmosher/eslint-plugin-import/issues/2035 is closed can be enabled
|
|
78
|
-
'unicorn/prefer-node-protocol': 'off', // Prefer using the `node:` protocol when importing Node.js builtin modules
|
|
79
|
-
'unicorn/prefer-negative-index': 'warn', // prefer negative index over .length - index for {String,Array,TypedArray}#slice() and Array#splice()
|
|
80
|
-
'unicorn/prefer-number-properties': 'warn', // prefer Number static properties over global ones
|
|
81
|
-
'unicorn/prefer-object-from-entries': 'warn', // prefer using Object.fromEntries(…) to transform a list of key-value pairs into an object
|
|
82
|
-
'unicorn/prefer-object-has-own': 'warn', // prefer Object.hasOwn(…) over Object.prototype.hasOwnProperty.call(…)
|
|
83
|
-
'unicorn/prefer-optional-catch-binding': 'off', // prefer omitting the catch binding parameter
|
|
84
|
-
'unicorn/prefer-prototype-methods': 'warn', // prefer borrowing methods from the prototype instead of the instance
|
|
85
|
-
'unicorn/prefer-query-selector': 'off', // prefer .querySelector() over .getElementById(), .querySelectorAll() over .getElementsByClassName() and .getElementsByTagName()
|
|
86
|
-
'unicorn/prefer-reflect-apply': 'off', // prefer Reflect.apply() over Function#apply()
|
|
87
|
-
'unicorn/prefer-regexp-test': 'warn', // prefer RegExp#test() over String#match() and RegExp#exec()
|
|
88
|
-
// Autofix can be breaking
|
|
89
|
-
'unicorn/prefer-set-has': 'warn', // prefer Set#has() over Array#includes() when checking for existence or non-existence
|
|
90
|
-
'unicorn/prefer-spread': 'error', // prefer the spread operator over Array.from()
|
|
91
|
-
'unicorn/prefer-string-replace-all': 'warn', // prefer String#replaceAll() over regex searches with the global flag
|
|
92
|
-
'unicorn/prefer-string-slice': 'warn', // prefer String#slice() over String#substr() and String#substring()
|
|
93
|
-
'unicorn/prefer-string-starts-ends-with': 'warn', // prefer String#startsWith() & String#endsWith() over more complex alternatives
|
|
94
|
-
'unicorn/prefer-string-trim-start-end': 'warn', // prefer String#trimStart() / String#trimEnd() over String#trimLeft() / String#trimRight()
|
|
95
|
-
'unicorn/prefer-switch': 'off', // prefer switch over multiple else-if
|
|
96
|
-
'unicorn/prefer-ternary': 'off', // prefer ternary expressions over simple if-else statements
|
|
97
|
-
// FIXME [@jakubmazanec]: enable when we support top-level await
|
|
98
|
-
'unicorn/prefer-top-level-await': 'off', // prefer top-level await over top-level promises and async function calls
|
|
99
|
-
'unicorn/prefer-type-error': 'warn', // enforce throwing TypeError in type checking conditions
|
|
100
|
-
'unicorn/prevent-abbreviations': 'off', // Prevent abbreviations.
|
|
101
|
-
'unicorn/require-array-join-separator': 'error', // enforce using the separator argument with Array#join()
|
|
102
|
-
'unicorn/require-number-to-fixed-digits-argument': 'error', // enforce using the digits argument with Number#toFixed()
|
|
103
|
-
'unicorn/require-post-message-target-origin': 'error', // enforce using the targetOrigin argument with window.postMessage()
|
|
104
|
-
'unicorn/string-content': 'off', // enforce better string content
|
|
105
|
-
'unicorn/throw-new-error': 'error', // require new when throwing an error
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export = config;
|
package/test/index.test.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { getExtendsList, ESLintOptions } from '../src';
|
|
2
|
-
import { getErrors } from './utils/getErrors';
|
|
3
|
-
|
|
4
|
-
interface OptionsShape {
|
|
5
|
-
filePath?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
describe('Check that eslint rules are correct', () => {
|
|
9
|
-
test.each<[ESLintOptions, string, OptionsShape?]>([
|
|
10
|
-
[{}, 'javascript.js', undefined],
|
|
11
|
-
[
|
|
12
|
-
{ typescript: true, future: true },
|
|
13
|
-
'typescript.ts',
|
|
14
|
-
{ filePath: `${process.cwd()}/packages/config-eslint/src/index.ts` },
|
|
15
|
-
],
|
|
16
|
-
[{ node: true }, 'node.js', undefined],
|
|
17
|
-
[{ future: true }, 'next.js', undefined],
|
|
18
|
-
[{ prettier: true }, 'prettier.js', undefined],
|
|
19
|
-
[
|
|
20
|
-
{ future: true, node: false, prettier: true, typescript: true },
|
|
21
|
-
'test.js',
|
|
22
|
-
{ filePath: 'index.test.js' },
|
|
23
|
-
],
|
|
24
|
-
[
|
|
25
|
-
{ future: true, node: false, prettier: true, typescript: true },
|
|
26
|
-
'combo.ts',
|
|
27
|
-
{ filePath: `${process.cwd()}/packages/config-eslint/src/index.ts` },
|
|
28
|
-
],
|
|
29
|
-
])(
|
|
30
|
-
'Config (options: %o) should work with file: %s and cliOptions: %o',
|
|
31
|
-
async (options, file, cliOptions) => {
|
|
32
|
-
const output = await getErrors(
|
|
33
|
-
{
|
|
34
|
-
extends: getExtendsList(options),
|
|
35
|
-
},
|
|
36
|
-
`packages/config-eslint/test/lint-files/${file}`,
|
|
37
|
-
cliOptions,
|
|
38
|
-
);
|
|
39
|
-
expect(output[0].messages.filter((item) => item.severity === 2)).toEqual([]);
|
|
40
|
-
expect(output[0].errorCount).toBe(0);
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
test.each<[ESLintOptions, string, OptionsShape | undefined, number]>([
|
|
45
|
-
[{}, 'javascript.js', undefined, 1],
|
|
46
|
-
[
|
|
47
|
-
{ typescript: true, future: true },
|
|
48
|
-
'typescript.ts',
|
|
49
|
-
{ filePath: `${process.cwd()}/packages/config-eslint/src/index.ts` },
|
|
50
|
-
1,
|
|
51
|
-
],
|
|
52
|
-
[{ node: true }, 'node.js', undefined, 1],
|
|
53
|
-
[{ future: true }, 'next.js', undefined, 2],
|
|
54
|
-
[{ prettier: true }, 'prettier.js', undefined, 4],
|
|
55
|
-
[
|
|
56
|
-
{ future: true, node: false, prettier: true, typescript: true },
|
|
57
|
-
'test.js',
|
|
58
|
-
{ filePath: 'index.test.js' },
|
|
59
|
-
1,
|
|
60
|
-
],
|
|
61
|
-
[
|
|
62
|
-
{ future: true, node: false, prettier: true, typescript: true },
|
|
63
|
-
'combo.ts',
|
|
64
|
-
{ filePath: `${process.cwd()}/packages/config-eslint/src/index.ts` },
|
|
65
|
-
1,
|
|
66
|
-
],
|
|
67
|
-
])(
|
|
68
|
-
'Config (options: %o) should throw error with file: %s and cliOptions: %o',
|
|
69
|
-
async (options, file, cliOptions, expectedErrors) => {
|
|
70
|
-
const output = await getErrors(
|
|
71
|
-
{
|
|
72
|
-
extends: getExtendsList(options),
|
|
73
|
-
},
|
|
74
|
-
`packages/config-eslint/test/lint-files/errors/${file}`,
|
|
75
|
-
cliOptions,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
expect(output[0].errorCount).toBe(expectedErrors);
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
});
|
package/test/lint-files/combo.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('test');
|
package/test/lint-files/next.js
DELETED
package/test/lint-files/node.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello');
|
package/test/lint-files/test.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface Interface {
|
|
2
|
-
(a: string): void;
|
|
3
|
-
test: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export const b: Interface = (a) => {
|
|
7
|
-
console.log(a);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
b.test = 'test string';
|
|
11
|
-
|
|
12
|
-
interface Item {
|
|
13
|
-
maybe?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const item: Item = {};
|
|
17
|
-
|
|
18
|
-
if (!item.maybe) {
|
|
19
|
-
console.log('test');
|
|
20
|
-
}
|
package/test/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"composite": false,
|
|
4
|
-
"emitDeclarationOnly": false,
|
|
5
|
-
"noEmit": true,
|
|
6
|
-
"rootDir": "."
|
|
7
|
-
},
|
|
8
|
-
"extends": "../../../tsconfig.options.json",
|
|
9
|
-
"include": [
|
|
10
|
-
"**/*",
|
|
11
|
-
"../types/**/*",
|
|
12
|
-
"../../../types/**/*"
|
|
13
|
-
],
|
|
14
|
-
"references": [
|
|
15
|
-
{
|
|
16
|
-
"path": ".."
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
package/test/utils/getErrors.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import eslint, { ESLint } from 'eslint';
|
|
3
|
-
|
|
4
|
-
export function getErrors(
|
|
5
|
-
config: ESLint.Options['baseConfig'],
|
|
6
|
-
fileToTest: string,
|
|
7
|
-
options?: Parameters<ESLint['lintText']>[1]
|
|
8
|
-
) {
|
|
9
|
-
const CLIEngine = eslint.ESLint;
|
|
10
|
-
|
|
11
|
-
const cli = new CLIEngine({
|
|
12
|
-
baseConfig: config,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
return cli.lintText(fs.readFileSync(fileToTest, 'utf8'), options);
|
|
16
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
|
|
5
|
-
const eslint = require('eslint/lib/rules');
|
|
6
|
-
const eslintPluginTypescript = require('@typescript-eslint/eslint-plugin');
|
|
7
|
-
const eslintPluginEslintComments = require('eslint-plugin-eslint-comments');
|
|
8
|
-
const eslintPluginImport = require('eslint-plugin-import');
|
|
9
|
-
const eslintPluginJest = require('eslint-plugin-jest');
|
|
10
|
-
const eslintPluginJsxA11y = require('eslint-plugin-jsx-a11y');
|
|
11
|
-
const eslintPluginNode = require('eslint-plugin-node');
|
|
12
|
-
const eslintPluginPrettier = require('eslint-plugin-prettier');
|
|
13
|
-
const eslintPluginPromise = require('eslint-plugin-promise');
|
|
14
|
-
const eslintPluginReact = require('eslint-plugin-react');
|
|
15
|
-
const eslintPluginReactHooks = require('eslint-plugin-react-hooks');
|
|
16
|
-
const eslintPluginTestingLibrary = require('eslint-plugin-testing-library');
|
|
17
|
-
const eslintPluginUnicorn = require('eslint-plugin-unicorn');
|
|
18
|
-
|
|
19
|
-
interface Rule {
|
|
20
|
-
meta: {
|
|
21
|
-
deprecated: boolean;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const eslintRules: string[] = [];
|
|
26
|
-
|
|
27
|
-
for (const [ruleName, rule] of eslint.entries()) {
|
|
28
|
-
if (!rule.meta.deprecated) {
|
|
29
|
-
eslintRules.push(ruleName);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const typescriptRules = (Object.entries(eslintPluginTypescript.rules) as Array<[string, Rule]>)
|
|
34
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
35
|
-
.map(([ruleName]) => `@typescript-eslint/${ruleName}`);
|
|
36
|
-
|
|
37
|
-
const eslintCommentsRules = (
|
|
38
|
-
Object.entries(eslintPluginEslintComments.rules) as Array<[string, Rule]>
|
|
39
|
-
)
|
|
40
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
41
|
-
.map(([ruleName]) => `eslint-comments/${ruleName}`);
|
|
42
|
-
|
|
43
|
-
const importRules = (Object.entries(eslintPluginImport.rules) as Array<[string, Rule]>)
|
|
44
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
45
|
-
.map(([ruleName]) => `import/${ruleName}`);
|
|
46
|
-
|
|
47
|
-
const jestRules = (Object.entries(eslintPluginJest.rules) as Array<[string, Rule]>)
|
|
48
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
49
|
-
.map(([ruleName]) => `jest/${ruleName}`);
|
|
50
|
-
|
|
51
|
-
const jsxA11yRules = (Object.entries(eslintPluginJsxA11y.rules) as Array<[string, Rule]>)
|
|
52
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
53
|
-
.map(([ruleName]) => `jsx-a11y/${ruleName}`);
|
|
54
|
-
|
|
55
|
-
const nodeRules = (Object.entries(eslintPluginNode.rules) as Array<[string, Rule]>)
|
|
56
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
57
|
-
.map(([ruleName]) => `node/${ruleName}`);
|
|
58
|
-
|
|
59
|
-
const prettierRules = (Object.entries(eslintPluginPrettier.rules) as Array<[string, Rule]>)
|
|
60
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
61
|
-
.map(([ruleName]) => `prettier/${ruleName}`);
|
|
62
|
-
|
|
63
|
-
const promiseRules = (Object.entries(eslintPluginPromise.rules) as Array<[string, Rule]>)
|
|
64
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
65
|
-
.map(([ruleName]) => `promise/${ruleName}`);
|
|
66
|
-
|
|
67
|
-
const reactRules = (Object.entries(eslintPluginReact.rules) as Array<[string, Rule]>)
|
|
68
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
69
|
-
.map(([ruleName]) => `react/${ruleName}`);
|
|
70
|
-
|
|
71
|
-
const reactHooksRules = (Object.entries(eslintPluginReactHooks.rules) as Array<[string, Rule]>)
|
|
72
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
73
|
-
.map(([ruleName]) => `react-hooks/${ruleName}`);
|
|
74
|
-
|
|
75
|
-
const testingLibraryRules = (
|
|
76
|
-
Object.entries(eslintPluginTestingLibrary.rules) as Array<[string, Rule]>
|
|
77
|
-
)
|
|
78
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
79
|
-
.map(([ruleName]) => `testing-library/${ruleName}`);
|
|
80
|
-
|
|
81
|
-
const unicornRules = (Object.entries(eslintPluginUnicorn.rules) as Array<[string, Rule]>)
|
|
82
|
-
.filter(([ruleName, rule]) => !rule.meta.deprecated)
|
|
83
|
-
.map(([ruleName]) => `unicorn/${ruleName}`);
|
|
84
|
-
|
|
85
|
-
export const allRules = [
|
|
86
|
-
...eslintRules,
|
|
87
|
-
...typescriptRules,
|
|
88
|
-
...eslintCommentsRules,
|
|
89
|
-
...importRules,
|
|
90
|
-
...jestRules,
|
|
91
|
-
...jsxA11yRules,
|
|
92
|
-
...nodeRules,
|
|
93
|
-
...prettierRules,
|
|
94
|
-
...promiseRules,
|
|
95
|
-
...reactRules,
|
|
96
|
-
...reactHooksRules,
|
|
97
|
-
...testingLibraryRules,
|
|
98
|
-
...unicornRules,
|
|
99
|
-
];
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { allRules } from './allRules';
|
|
2
|
-
|
|
3
|
-
import a11yRulesConfig from '../../src/rules/a11y';
|
|
4
|
-
import eslintRulesConfig from '../../src/rules/eslint';
|
|
5
|
-
import eslintCommentsRulesConfig from '../../src/rules/eslint-comments';
|
|
6
|
-
import importRulesConfig from '../../src/rules/import';
|
|
7
|
-
import jestRulesConfig from '../../src/rules/jest';
|
|
8
|
-
import nodeRulesConfig from '../../src/rules/node';
|
|
9
|
-
import prettierRulesConfig from '../../src/rules/prettier';
|
|
10
|
-
import promiseRulesConfig from '../../src/rules/promise';
|
|
11
|
-
import reactHooksRulesConfig from '../../src/rules/react-hooks';
|
|
12
|
-
import reactRulesConfig from '../../src/rules/react';
|
|
13
|
-
import testingLibraryRulesConfig from '../../src/rules/testing-library';
|
|
14
|
-
import typescriptRulesConfig from '../../src/rules/typescript';
|
|
15
|
-
import unicornRulesConfig from '../../src/rules/unicorn';
|
|
16
|
-
import { RuleOptions, RuleSetting } from '@beemo/driver-eslint';
|
|
17
|
-
|
|
18
|
-
const filerDisabledRules = ([ruleName, rule]: [
|
|
19
|
-
string,
|
|
20
|
-
RuleSetting | [RuleSetting, ...RuleOptions[]],
|
|
21
|
-
]) => {
|
|
22
|
-
if (Array.isArray(rule)) {
|
|
23
|
-
if (rule[0] === 0 || rule[0] === '0' || rule[0] === 'off') {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (rule === 0 || rule === '0' || rule === 'off') {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return true;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const a11yRules = Object.entries(a11yRulesConfig!).map(([ruleName]) => ruleName);
|
|
36
|
-
const eslintRules = Object.entries(eslintRulesConfig!).map(([ruleName]) => ruleName);
|
|
37
|
-
const eslintCommentsRules = Object.entries(eslintCommentsRulesConfig!).map(
|
|
38
|
-
([ruleName]) => ruleName,
|
|
39
|
-
);
|
|
40
|
-
const importRules = Object.entries(importRulesConfig!).map(([ruleName]) => ruleName);
|
|
41
|
-
const jestRules = Object.entries(jestRulesConfig!).map(([ruleName]) => ruleName);
|
|
42
|
-
const nodeRules = Object.entries(nodeRulesConfig!).map(([ruleName]) => ruleName);
|
|
43
|
-
const prettierRules = Object.entries(prettierRulesConfig!).map(([ruleName]) => ruleName);
|
|
44
|
-
const promiseRules = Object.entries(promiseRulesConfig!).map(([ruleName]) => ruleName);
|
|
45
|
-
const reactHookRules = Object.entries(reactHooksRulesConfig!).map(([ruleName]) => ruleName);
|
|
46
|
-
const reactRules = Object.entries(reactRulesConfig!).map(([ruleName]) => ruleName);
|
|
47
|
-
const testingLibraryRules = Object.entries(testingLibraryRulesConfig!).map(
|
|
48
|
-
([ruleName]) => ruleName,
|
|
49
|
-
);
|
|
50
|
-
const typescriptRules = Object.entries(typescriptRulesConfig!).map(([ruleName]) => ruleName);
|
|
51
|
-
const unicornRules = Object.entries(unicornRulesConfig!).map(([ruleName]) => ruleName);
|
|
52
|
-
|
|
53
|
-
const usedRules = [
|
|
54
|
-
...a11yRules,
|
|
55
|
-
...eslintRules,
|
|
56
|
-
...eslintCommentsRules,
|
|
57
|
-
...importRules,
|
|
58
|
-
...jestRules,
|
|
59
|
-
...nodeRules,
|
|
60
|
-
...prettierRules,
|
|
61
|
-
...promiseRules,
|
|
62
|
-
...reactHookRules,
|
|
63
|
-
...reactRules,
|
|
64
|
-
...testingLibraryRules,
|
|
65
|
-
...typescriptRules,
|
|
66
|
-
...unicornRules,
|
|
67
|
-
].sort();
|
|
68
|
-
|
|
69
|
-
const missingRules: string[] = [];
|
|
70
|
-
|
|
71
|
-
allRules.forEach((ruleName) => {
|
|
72
|
-
if (!usedRules.includes(ruleName)) {
|
|
73
|
-
missingRules.push(ruleName);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
missingRules.sort();
|
|
78
|
-
|
|
79
|
-
const deprecatedRules: string[] = [];
|
|
80
|
-
|
|
81
|
-
usedRules.forEach((ruleName) => {
|
|
82
|
-
if (!allRules.includes(ruleName)) {
|
|
83
|
-
deprecatedRules.push(ruleName);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
deprecatedRules.sort();
|
|
88
|
-
|
|
89
|
-
console.log('Deprecated rules:', deprecatedRules);
|
|
90
|
-
console.log('Missing rules:', missingRules);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declarationDir": "lib",
|
|
4
|
-
"outDir": "lib",
|
|
5
|
-
"rootDir": "../../"
|
|
6
|
-
},
|
|
7
|
-
"exclude": [
|
|
8
|
-
"lib",
|
|
9
|
-
"tests"
|
|
10
|
-
],
|
|
11
|
-
"extends": "../../../../tsconfig.options.json",
|
|
12
|
-
"include": [
|
|
13
|
-
"./**/*",
|
|
14
|
-
"../../src/**/*",
|
|
15
|
-
"../../../../types/**/*"
|
|
16
|
-
]
|
|
17
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declarationDir": "lib",
|
|
4
|
-
"outDir": "lib",
|
|
5
|
-
"rootDir": "src"
|
|
6
|
-
},
|
|
7
|
-
"exclude": [
|
|
8
|
-
"lib",
|
|
9
|
-
"tests"
|
|
10
|
-
],
|
|
11
|
-
"extends": "../../tsconfig.options.json",
|
|
12
|
-
"include": [
|
|
13
|
-
"src/**/*",
|
|
14
|
-
"types/**/*",
|
|
15
|
-
"../../types/**/*"
|
|
16
|
-
],
|
|
17
|
-
"references": [
|
|
18
|
-
{
|
|
19
|
-
"path": "../lumos-common"
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}
|