@w5s/eslint-config 2.4.5 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +8054 -3
- package/dist/index.js +4171 -22
- package/dist/index.js.map +1 -0
- package/package.json +26 -17
- package/src/config/createRules.ts +5 -0
- package/src/config/es.ts +58 -0
- package/src/config/ignores.ts +84 -0
- package/src/config/imports.ts +32 -0
- package/src/config/jsdoc.ts +53 -0
- package/src/config/jsonc.ts +237 -0
- package/src/config/node.ts +42 -0
- package/src/config/stylistic.ts +50 -0
- package/src/config/test.ts +44 -0
- package/src/config/ts.ts +97 -0
- package/src/config/unicorn.ts +68 -0
- package/src/config/yml.ts +70 -0
- package/src/config.ts +11 -0
- package/src/defineConfig.ts +62 -0
- package/src/index.ts +3 -31
- package/src/type/Config.ts +5 -0
- package/src/type/PluginOptionsBase.ts +14 -0
- package/src/type/StylisticConfig.ts +39 -0
- package/src/type.ts +3 -0
- package/src/typegen/.keep +0 -0
- package/src/typegen/import.d.ts +501 -0
- package/src/typegen/jsdoc.d.ts +1155 -0
- package/src/typegen/jsonc.d.ts +500 -0
- package/src/typegen/node.d.ts +529 -0
- package/src/typegen/style.d.ts +1637 -0
- package/src/typegen/test.d.ts +430 -0
- package/src/typegen/ts.d.ts +1872 -0
- package/src/typegen/unicorn.d.ts +913 -0
- package/src/typegen/yml.d.ts +363 -0
- package/dist/es.d.ts +0 -3
- package/dist/es.js +0 -10
- package/dist/jest.d.ts +0 -3
- package/dist/jest.js +0 -20
- package/dist/json.d.ts +0 -3
- package/dist/json.js +0 -14
- package/dist/rules/es/base.d.ts +0 -4
- package/dist/rules/es/base.js +0 -71
- package/dist/rules/es/import.d.ts +0 -3
- package/dist/rules/es/import.js +0 -74
- package/dist/rules/es/jsdoc.d.ts +0 -3
- package/dist/rules/es/jsdoc.js +0 -21
- package/dist/rules/es/node.d.ts +0 -3
- package/dist/rules/es/node.js +0 -20
- package/dist/rules/es/promise.d.ts +0 -3
- package/dist/rules/es/promise.js +0 -11
- package/dist/rules/es/unicorn.d.ts +0 -3
- package/dist/rules/es/unicorn.js +0 -72
- package/dist/rules/es.d.ts +0 -3
- package/dist/rules/es.js +0 -14
- package/dist/rules/ignore.d.ts +0 -3
- package/dist/rules/ignore.js +0 -54
- package/dist/rules/jest.d.ts +0 -3
- package/dist/rules/jest.js +0 -64
- package/dist/rules/jsonc.d.ts +0 -3
- package/dist/rules/jsonc.js +0 -183
- package/dist/rules/prettier.d.ts +0 -3
- package/dist/rules/prettier.js +0 -13
- package/dist/rules/typescript.d.ts +0 -3
- package/dist/rules/typescript.js +0 -249
- package/dist/rules/yml.d.ts +0 -3
- package/dist/rules/yml.js +0 -21
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/typescript.d.ts +0 -3
- package/dist/typescript.js +0 -21
- package/dist/yml.d.ts +0 -3
- package/dist/yml.js +0 -19
- package/src/es.ts +0 -12
- package/src/jest.ts +0 -18
- package/src/json.ts +0 -12
- package/src/rules/es/base.ts +0 -83
- package/src/rules/es/import.ts +0 -81
- package/src/rules/es/jsdoc.ts +0 -23
- package/src/rules/es/node.ts +0 -21
- package/src/rules/es/promise.ts +0 -12
- package/src/rules/es/unicorn.ts +0 -74
- package/src/rules/es.ts +0 -21
- package/src/rules/ignore.ts +0 -54
- package/src/rules/jest.ts +0 -68
- package/src/rules/jsonc.ts +0 -187
- package/src/rules/prettier.ts +0 -11
- package/src/rules/typescript.ts +0 -255
- package/src/rules/yml.ts +0 -22
- package/src/typescript.ts +0 -24
- package/src/yml.ts +0 -18
package/src/rules/es/unicorn.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { ESLintConfig } from '@w5s/dev';
|
|
2
|
-
import type eslint from 'eslint';
|
|
3
|
-
// @ts-ignore unicorn config is not typed
|
|
4
|
-
import unicornConfig from 'eslint-plugin-unicorn';
|
|
5
|
-
|
|
6
|
-
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
7
|
-
unicornConfig.configs.recommended,
|
|
8
|
-
{
|
|
9
|
-
// extends: ['plugin:unicorn/recommended'],
|
|
10
|
-
plugins: ['unicorn'],
|
|
11
|
-
rules: {
|
|
12
|
-
'unicorn/better-regex': 'error',
|
|
13
|
-
'unicorn/catch-error-name': ['error', { name: 'error' }],
|
|
14
|
-
'unicorn/custom-error-definition': 'error',
|
|
15
|
-
'unicorn/error-message': 'error',
|
|
16
|
-
'unicorn/explicit-length-check': ['error', { 'non-zero': 'greater-than' }],
|
|
17
|
-
'unicorn/filename-case': 'off',
|
|
18
|
-
'unicorn/import-index': 'off', // Not playing well with ES Module
|
|
19
|
-
'unicorn/new-for-builtins': 'off', // error, @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/122
|
|
20
|
-
'unicorn/no-abusive-eslint-disable': 'error',
|
|
21
|
-
'unicorn/no-array-instanceof': 'error',
|
|
22
|
-
'unicorn/no-console-spaces': 'off',
|
|
23
|
-
'unicorn/no-fn-reference-in-iterator': 'off', // error ?
|
|
24
|
-
'unicorn/no-for-loop': 'error',
|
|
25
|
-
'unicorn/no-hex-escape': 'error',
|
|
26
|
-
'unicorn/no-new-buffer': 'error',
|
|
27
|
-
'unicorn/no-null': 'off', // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/612
|
|
28
|
-
'unicorn/no-process-exit': 'off',
|
|
29
|
-
'unicorn/no-unreadable-array-destructuring': 'off',
|
|
30
|
-
'unicorn/no-unsafe-regex': 'error',
|
|
31
|
-
'unicorn/no-unused-properties': 'warn',
|
|
32
|
-
'unicorn/no-useless-undefined': 'off',
|
|
33
|
-
'unicorn/no-zero-fractions': 'error',
|
|
34
|
-
'unicorn/number-literal-case': 'error',
|
|
35
|
-
'unicorn/prefer-add-event-listener': 'off',
|
|
36
|
-
'unicorn/prefer-event-key': 'error',
|
|
37
|
-
'unicorn/prefer-exponentiation-operator': 'error',
|
|
38
|
-
'unicorn/prefer-flat-map': 'error',
|
|
39
|
-
'unicorn/prefer-includes': 'error',
|
|
40
|
-
'unicorn/prefer-node-append': 'error',
|
|
41
|
-
'unicorn/prefer-node-remove': 'error',
|
|
42
|
-
'unicorn/prefer-number-properties': 'error',
|
|
43
|
-
'unicorn/prefer-query-selector': 'error',
|
|
44
|
-
'unicorn/prefer-set-has': 'off',
|
|
45
|
-
'unicorn/prefer-spread': 'off',
|
|
46
|
-
'unicorn/prefer-starts-ends-with': 'error',
|
|
47
|
-
'unicorn/prefer-text-content': 'error',
|
|
48
|
-
'unicorn/prefer-type-error': 'error',
|
|
49
|
-
'unicorn/throw-new-error': 'off', // Creating errors with call signature is OK
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
overrides: [
|
|
54
|
-
{
|
|
55
|
-
files: ['**/*.config.cjs', '**/*.config.js'],
|
|
56
|
-
rules: {
|
|
57
|
-
'unicorn/prefer-module': 'off',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
rules: {
|
|
62
|
-
'unicorn/consistent-destructuring': 'off',
|
|
63
|
-
'unicorn/consistent-function-scoping': 'off', // Too many false positive
|
|
64
|
-
'unicorn/no-array-callback-reference': 'off', // Many false positive reported
|
|
65
|
-
'unicorn/no-array-for-each': 'off', // This rule could change browser compatibility
|
|
66
|
-
'unicorn/no-array-method-this-argument': 'off', // Many false positive reported
|
|
67
|
-
'unicorn/no-array-reduce': 'off', // Array#reduce can be used
|
|
68
|
-
'unicorn/no-object-as-default-parameter': 'off',
|
|
69
|
-
'unicorn/prefer-default-parameters': 'off',
|
|
70
|
-
'unicorn/prevent-abbreviations': 'off', // This rule is so dangerous : it potentially break code while fixing in many cases !!
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
-
export = config;
|
package/src/rules/es.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type eslint from 'eslint';
|
|
2
|
-
import { ESLintConfig } from '@w5s/dev';
|
|
3
|
-
import baseConfig from './es/base.js';
|
|
4
|
-
import promiseConfig from './es/promise.js';
|
|
5
|
-
import jsdocConfig from './es/jsdoc.js';
|
|
6
|
-
import importConfig from './es/import.js';
|
|
7
|
-
import unicornConfig from './es/unicorn.js';
|
|
8
|
-
import nodeConfig from './es/node.js';
|
|
9
|
-
|
|
10
|
-
// import prettierConfig from './prettier.js';
|
|
11
|
-
|
|
12
|
-
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
13
|
-
baseConfig,
|
|
14
|
-
promiseConfig,
|
|
15
|
-
jsdocConfig,
|
|
16
|
-
importConfig,
|
|
17
|
-
unicornConfig,
|
|
18
|
-
nodeConfig,
|
|
19
|
-
// prettierConfig
|
|
20
|
-
);
|
|
21
|
-
export = config;
|
package/src/rules/ignore.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import nodePath from 'node:path';
|
|
3
|
-
import process from 'node:process';
|
|
4
|
-
import type eslint from 'eslint';
|
|
5
|
-
import findUp from 'find-up';
|
|
6
|
-
import parseGitignore from 'parse-gitignore';
|
|
7
|
-
|
|
8
|
-
const getGitignore = (prefix = '') => {
|
|
9
|
-
const cwd = process.cwd();
|
|
10
|
-
const gitIgnoreFile = findUp.sync(nodePath.join(prefix, '.gitignore'), { cwd });
|
|
11
|
-
if (gitIgnoreFile != null) {
|
|
12
|
-
// eslint-disable-next-line n/no-sync
|
|
13
|
-
const { patterns } = parseGitignore.parse(readFileSync(gitIgnoreFile));
|
|
14
|
-
const returnValue = patterns.map((pattern) => nodePath.join(prefix, pattern));
|
|
15
|
-
return returnValue;
|
|
16
|
-
}
|
|
17
|
-
return [];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const config: eslint.Linter.Config = {
|
|
21
|
-
ignorePatterns: [
|
|
22
|
-
'!.*',
|
|
23
|
-
'.docusaurus',
|
|
24
|
-
'.yarn',
|
|
25
|
-
'.common/',
|
|
26
|
-
'.config/package-lock.json',
|
|
27
|
-
'.config/yarn.lock',
|
|
28
|
-
'.git/',
|
|
29
|
-
'.go/',
|
|
30
|
-
'.modules/',
|
|
31
|
-
'.pnpm-store/',
|
|
32
|
-
'.venv/',
|
|
33
|
-
'deprecated/',
|
|
34
|
-
'angular.json',
|
|
35
|
-
'esbuild.js',
|
|
36
|
-
'package-lock.json',
|
|
37
|
-
'pnpm-lock.yaml',
|
|
38
|
-
'slim.report.json',
|
|
39
|
-
'test-output/',
|
|
40
|
-
'venv/',
|
|
41
|
-
'yarn.lock',
|
|
42
|
-
'_generated_/',
|
|
43
|
-
'**/vendor/**',
|
|
44
|
-
'**/vendors/**',
|
|
45
|
-
'*.min.*',
|
|
46
|
-
'*.toml',
|
|
47
|
-
'*.timestamp-*.mjs', // esbuild/vite temporary files
|
|
48
|
-
...getGitignore(),
|
|
49
|
-
...getGitignore('android'),
|
|
50
|
-
...getGitignore('ios'),
|
|
51
|
-
],
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export = config;
|
package/src/rules/jest.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ESLintConfig } from '@w5s/dev';
|
|
2
|
-
import type eslint from 'eslint';
|
|
3
|
-
|
|
4
|
-
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
5
|
-
{
|
|
6
|
-
env: {
|
|
7
|
-
'jest/globals': true,
|
|
8
|
-
},
|
|
9
|
-
extends: ['plugin:jest/recommended'],
|
|
10
|
-
globals: {
|
|
11
|
-
context: true,
|
|
12
|
-
},
|
|
13
|
-
plugins: ['jest'],
|
|
14
|
-
rules: {
|
|
15
|
-
'jest/consistent-test-it': 'error',
|
|
16
|
-
'jest/expect-expect': 'off', // Disabled because it does not handle functions that does the expect
|
|
17
|
-
'jest/no-alias-methods': 'error',
|
|
18
|
-
'jest/prefer-spy-on': 'error',
|
|
19
|
-
'jest/prefer-to-contain': 'error',
|
|
20
|
-
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
|
|
21
|
-
},
|
|
22
|
-
settings: {
|
|
23
|
-
jest: {
|
|
24
|
-
// Compatibility with mocha, cypress, etc.
|
|
25
|
-
globalAliases: {
|
|
26
|
-
describe: ['context'],
|
|
27
|
-
fdescribe: ['fcontext'],
|
|
28
|
-
xdescribe: ['xcontext'],
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
version: 'latest',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
// NodeJS loose config
|
|
36
|
-
{
|
|
37
|
-
rules: {
|
|
38
|
-
'n/no-sync': 'off',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
/**
|
|
42
|
-
* Unicorn less strict to help writing tests
|
|
43
|
-
*/
|
|
44
|
-
{
|
|
45
|
-
rules: {
|
|
46
|
-
'unicorn/consistent-function-scoping': 'off',
|
|
47
|
-
'unicorn/no-useless-undefined': 'off',
|
|
48
|
-
'unicorn/prefer-module': 'off',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* Typescript config is set to be less strict because we often have "hack", "mock" in tests
|
|
53
|
-
*/
|
|
54
|
-
{
|
|
55
|
-
rules: {
|
|
56
|
-
'@typescript-eslint/dot-notation': ESLintConfig.fixme(undefined), // eslint-plugin-jest seems to break this rule
|
|
57
|
-
'@typescript-eslint/naming-convention': 'off',
|
|
58
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
59
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
60
|
-
'@typescript-eslint/no-unsafe-call': 'off',
|
|
61
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
62
|
-
'@typescript-eslint/no-unsafe-return': 'off',
|
|
63
|
-
'@typescript-eslint/restrict-template-expressions': 'off',
|
|
64
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
);
|
|
68
|
-
export = config;
|
package/src/rules/jsonc.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/* cspell:disable */
|
|
2
|
-
import type eslint from 'eslint';
|
|
3
|
-
|
|
4
|
-
// https://github.com/keithamus/sort-package-json/blob/master/defaultRules.md
|
|
5
|
-
|
|
6
|
-
const config: eslint.Linter.Config = {
|
|
7
|
-
extends: ['plugin:jsonc/recommended-with-jsonc', 'plugin:jsonc/prettier'],
|
|
8
|
-
overrides: [
|
|
9
|
-
{
|
|
10
|
-
files: ['tsconfig*.json'],
|
|
11
|
-
rules: {
|
|
12
|
-
'jsonc/sort-keys': [
|
|
13
|
-
'error',
|
|
14
|
-
{
|
|
15
|
-
order: ['$schema', 'display', 'extends', 'compilerOptions', 'include', 'exclude', 'files', 'references'],
|
|
16
|
-
pathPattern: '^$',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
order: { type: 'asc' },
|
|
20
|
-
pathPattern: '.*',
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
files: ['package.json'],
|
|
27
|
-
rules: {
|
|
28
|
-
'jsonc/sort-keys': [
|
|
29
|
-
'error',
|
|
30
|
-
{
|
|
31
|
-
order: [
|
|
32
|
-
'$schema',
|
|
33
|
-
'name',
|
|
34
|
-
'displayName',
|
|
35
|
-
'version',
|
|
36
|
-
'private',
|
|
37
|
-
'description',
|
|
38
|
-
'categories',
|
|
39
|
-
'keywords',
|
|
40
|
-
'homepage',
|
|
41
|
-
'bugs',
|
|
42
|
-
'repository',
|
|
43
|
-
'funding',
|
|
44
|
-
'license',
|
|
45
|
-
'qna',
|
|
46
|
-
'author',
|
|
47
|
-
'maintainers', // Key order (per item): name, email, url
|
|
48
|
-
'contributors', // Key order (per item): name, email, url
|
|
49
|
-
'publisher',
|
|
50
|
-
'sideEffects',
|
|
51
|
-
'type',
|
|
52
|
-
'imports',
|
|
53
|
-
'exports',
|
|
54
|
-
'main',
|
|
55
|
-
'svelte',
|
|
56
|
-
'umd:main',
|
|
57
|
-
'jsdelivr',
|
|
58
|
-
'unpkg',
|
|
59
|
-
'module',
|
|
60
|
-
'source',
|
|
61
|
-
'jsnext:main',
|
|
62
|
-
'browser',
|
|
63
|
-
'react-native',
|
|
64
|
-
'types',
|
|
65
|
-
'typesVersions',
|
|
66
|
-
'typings',
|
|
67
|
-
'style',
|
|
68
|
-
'example',
|
|
69
|
-
'examplestyle',
|
|
70
|
-
'assets',
|
|
71
|
-
'bin',
|
|
72
|
-
'man',
|
|
73
|
-
'directories', // Key order: lib, bin, man, doc, example, test
|
|
74
|
-
'files', // Unique items
|
|
75
|
-
'workspaces',
|
|
76
|
-
'binary', // Key order: module_name, module_path, remote_path, package_name, host
|
|
77
|
-
'scripts', // Script sort
|
|
78
|
-
'betterScripts', // Script sort
|
|
79
|
-
'contributes',
|
|
80
|
-
'activationEvents', // Unique items
|
|
81
|
-
'husky', // Sorts the hooks field using git hook sort
|
|
82
|
-
'simple-git-hooks', // Key sort using git hook sort
|
|
83
|
-
'pre-commit',
|
|
84
|
-
'commitlint',
|
|
85
|
-
'lint-staged',
|
|
86
|
-
'config',
|
|
87
|
-
'nodemonConfig',
|
|
88
|
-
'browserify',
|
|
89
|
-
'babel',
|
|
90
|
-
'browserslist',
|
|
91
|
-
'xo',
|
|
92
|
-
'prettier', // Prettier sort
|
|
93
|
-
'eslintConfig', // ESLint sort
|
|
94
|
-
'eslintIgnore',
|
|
95
|
-
'npmpackagejsonlint', // Key sort (also recognizes: npmPackageJsonLintConfig, npmpkgjsonlint)
|
|
96
|
-
'release',
|
|
97
|
-
'remarkConfig',
|
|
98
|
-
'stylelint',
|
|
99
|
-
'ava',
|
|
100
|
-
'jest',
|
|
101
|
-
'mocha',
|
|
102
|
-
'nyc',
|
|
103
|
-
'tap',
|
|
104
|
-
'resolutions',
|
|
105
|
-
'dependencies',
|
|
106
|
-
'devDependencies',
|
|
107
|
-
'dependenciesMeta', // Key sort (deep)
|
|
108
|
-
'peerDependencies',
|
|
109
|
-
'peerDependenciesMeta', // Key sort (deep)
|
|
110
|
-
'optionalDependencies',
|
|
111
|
-
'bundledDependencies',
|
|
112
|
-
'bundleDependencies',
|
|
113
|
-
'extensionPack',
|
|
114
|
-
'extensionDependencies',
|
|
115
|
-
'flat',
|
|
116
|
-
'packageManager',
|
|
117
|
-
'engines',
|
|
118
|
-
'engineStrict',
|
|
119
|
-
'volta', // Key order: node, npm, yarn
|
|
120
|
-
'languageName',
|
|
121
|
-
'os',
|
|
122
|
-
'cpu',
|
|
123
|
-
'preferGlobal',
|
|
124
|
-
'publishConfig',
|
|
125
|
-
'icon',
|
|
126
|
-
'badges', // Key order (per item): description, url, href
|
|
127
|
-
'galleryBanner',
|
|
128
|
-
'preview',
|
|
129
|
-
'markdown',
|
|
130
|
-
],
|
|
131
|
-
pathPattern: '^$',
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
order: ['url', 'email'],
|
|
135
|
-
pathPattern: `^bugs$`,
|
|
136
|
-
},
|
|
137
|
-
...['repository', 'funding', 'license', 'author'].map((key) => ({
|
|
138
|
-
order: ['type', 'name', 'email', 'url'],
|
|
139
|
-
pathPattern: `^${key}$`,
|
|
140
|
-
})),
|
|
141
|
-
...['scripts', 'betterScripts'].map((key) => ({
|
|
142
|
-
order: { type: 'asc' },
|
|
143
|
-
pathPattern: `^${key}$`,
|
|
144
|
-
})),
|
|
145
|
-
...[
|
|
146
|
-
'bin',
|
|
147
|
-
'contributes',
|
|
148
|
-
'commitlint',
|
|
149
|
-
'config',
|
|
150
|
-
'nodemonConfig',
|
|
151
|
-
'browserify',
|
|
152
|
-
'babel',
|
|
153
|
-
'xo',
|
|
154
|
-
'release',
|
|
155
|
-
'remarkConfig',
|
|
156
|
-
'ava',
|
|
157
|
-
'jest',
|
|
158
|
-
'mocha',
|
|
159
|
-
'nyc',
|
|
160
|
-
'tap',
|
|
161
|
-
'resolutions',
|
|
162
|
-
'engines',
|
|
163
|
-
'engineStrict',
|
|
164
|
-
'preferGlobal',
|
|
165
|
-
'publishConfig',
|
|
166
|
-
'galleryBanner',
|
|
167
|
-
].map((key) => ({
|
|
168
|
-
order: { type: 'asc' },
|
|
169
|
-
pathPattern: `^${key}$`,
|
|
170
|
-
})),
|
|
171
|
-
{
|
|
172
|
-
order: { type: 'asc' },
|
|
173
|
-
pathPattern: '^(?:dev|peer|optional|bundled|extension)?[Dd]ependencies$',
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
order: ['types', 'require', 'import'],
|
|
177
|
-
pathPattern: '^exports.*$',
|
|
178
|
-
},
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
parser: 'jsonc-eslint-parser',
|
|
184
|
-
plugins: ['jsonc'],
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
export = config;
|
package/src/rules/prettier.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type eslint from 'eslint';
|
|
2
|
-
import prettierConfig from '@w5s/prettier-config';
|
|
3
|
-
|
|
4
|
-
const config: eslint.Linter.Config = {
|
|
5
|
-
extends: ['prettier'],
|
|
6
|
-
plugins: ['prettier'],
|
|
7
|
-
rules: {
|
|
8
|
-
'prettier/prettier': ['error', prettierConfig],
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
export = config;
|
package/src/rules/typescript.ts
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import type eslint from 'eslint';
|
|
2
|
-
import { ESLintConfig } from '@w5s/dev';
|
|
3
|
-
import baseConfig from './es/base.js';
|
|
4
|
-
import importConfig from './es/import.js';
|
|
5
|
-
|
|
6
|
-
// Inspired by https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/lib/shared.js
|
|
7
|
-
|
|
8
|
-
// Fix Hack : TS plugin seems to modify the rules
|
|
9
|
-
const deepClone = <T extends Partial<eslint.Linter.RulesRecord> | undefined>(anyValue: T): any =>
|
|
10
|
-
structuredClone(anyValue);
|
|
11
|
-
const baseRules = deepClone(baseConfig.rules) ?? {};
|
|
12
|
-
const baseImportRules = deepClone(importConfig.rules) ?? {};
|
|
13
|
-
|
|
14
|
-
const duplicateTSC = 'off'; // = "off because tsc already checks that"
|
|
15
|
-
|
|
16
|
-
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
17
|
-
/**
|
|
18
|
-
* Plugin rules
|
|
19
|
-
*/
|
|
20
|
-
{
|
|
21
|
-
extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'],
|
|
22
|
-
parser: '@typescript-eslint/parser',
|
|
23
|
-
parserOptions: {
|
|
24
|
-
sourceType: 'module',
|
|
25
|
-
},
|
|
26
|
-
plugins: ['@typescript-eslint', 'import'],
|
|
27
|
-
rules: {
|
|
28
|
-
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
29
|
-
'@typescript-eslint/ban-ts-comment': [
|
|
30
|
-
'warn',
|
|
31
|
-
{
|
|
32
|
-
minimumDescriptionLength: 3,
|
|
33
|
-
'ts-check': false,
|
|
34
|
-
'ts-expect-error': 'allow-with-description',
|
|
35
|
-
'ts-ignore': 'allow-with-description',
|
|
36
|
-
'ts-nocheck': true,
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
'@typescript-eslint/brace-style': baseRules['brace-style'],
|
|
40
|
-
'@typescript-eslint/comma-dangle': [
|
|
41
|
-
baseRules['comma-dangle'][0],
|
|
42
|
-
{
|
|
43
|
-
...baseRules['comma-dangle'][1],
|
|
44
|
-
enums: baseRules['comma-dangle'][1].arrays,
|
|
45
|
-
generics: baseRules['comma-dangle'][1].arrays,
|
|
46
|
-
tuples: baseRules['comma-dangle'][1].arrays,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
'@typescript-eslint/comma-spacing': baseRules['comma-spacing'],
|
|
50
|
-
'@typescript-eslint/consistent-type-assertions': [
|
|
51
|
-
'error',
|
|
52
|
-
{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' },
|
|
53
|
-
],
|
|
54
|
-
'@typescript-eslint/default-param-last': baseRules['default-param-last'],
|
|
55
|
-
'@typescript-eslint/dot-notation': baseRules['dot-notation'],
|
|
56
|
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
57
|
-
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
58
|
-
'@typescript-eslint/func-call-spacing': baseRules['func-call-spacing'],
|
|
59
|
-
'@typescript-eslint/indent': baseRules.indent,
|
|
60
|
-
'@typescript-eslint/keyword-spacing': baseRules['keyword-spacing'],
|
|
61
|
-
// '@typescript-eslint/lines-between-class-members': baseRules['lines-between-class-members'],
|
|
62
|
-
'@typescript-eslint/member-delimiter-style': 'error',
|
|
63
|
-
'@typescript-eslint/naming-convention': [
|
|
64
|
-
'error',
|
|
65
|
-
{
|
|
66
|
-
format: ['PascalCase', 'camelCase'],
|
|
67
|
-
leadingUnderscore: 'allow',
|
|
68
|
-
selector: 'default',
|
|
69
|
-
trailingUnderscore: 'allow',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
|
|
73
|
-
leadingUnderscore: 'allow',
|
|
74
|
-
selector: 'variable',
|
|
75
|
-
trailingUnderscore: 'allow',
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
|
|
79
|
-
leadingUnderscore: 'allowSingleOrDouble',
|
|
80
|
-
selector: 'memberLike',
|
|
81
|
-
trailingUnderscore: 'allowDouble',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
format: ['PascalCase'],
|
|
85
|
-
selector: 'typeLike',
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
'@typescript-eslint/no-array-constructor': baseRules['no-array-constructor'],
|
|
89
|
-
'@typescript-eslint/no-base-to-string': 'error',
|
|
90
|
-
'@typescript-eslint/no-dupe-class-members': baseRules['no-dupe-class-members'],
|
|
91
|
-
'@typescript-eslint/no-empty-function': baseRules['no-empty-function'],
|
|
92
|
-
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
|
|
93
|
-
'@typescript-eslint/no-empty-object-type': 'off',
|
|
94
|
-
'@typescript-eslint/no-explicit-any': 'off', // if any is explicit then it's wanted
|
|
95
|
-
'@typescript-eslint/no-extra-parens': baseRules['no-extra-parens'],
|
|
96
|
-
'@typescript-eslint/no-extra-semi': baseRules['no-extra-semi'],
|
|
97
|
-
'@typescript-eslint/no-inferrable-types': 'error',
|
|
98
|
-
'@typescript-eslint/no-loop-func': baseRules['no-loop-func'],
|
|
99
|
-
'@typescript-eslint/no-loss-of-precision': baseRules['no-loss-of-precision'],
|
|
100
|
-
'@typescript-eslint/no-magic-numbers': baseRules['no-magic-numbers'],
|
|
101
|
-
'@typescript-eslint/no-misused-new': 'error',
|
|
102
|
-
'@typescript-eslint/no-namespace': 'off', // We don't agree with community, namespaces are great and not deprecated
|
|
103
|
-
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
104
|
-
'@typescript-eslint/no-redeclare': ESLintConfig.fixme(baseRules['no-redeclare']),
|
|
105
|
-
'@typescript-eslint/no-require-imports': 'error',
|
|
106
|
-
'@typescript-eslint/no-shadow': baseRules['no-shadow'],
|
|
107
|
-
'@typescript-eslint/no-this-alias': 'error',
|
|
108
|
-
'@typescript-eslint/no-unnecessary-condition': 'error',
|
|
109
|
-
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
110
|
-
'@typescript-eslint/no-unused-expressions': baseRules['no-unused-expressions'],
|
|
111
|
-
'@typescript-eslint/no-unused-vars': baseRules['no-unused-vars'],
|
|
112
|
-
'@typescript-eslint/no-use-before-define': baseRules['no-use-before-define'],
|
|
113
|
-
'@typescript-eslint/no-useless-constructor': baseRules['no-useless-constructor'],
|
|
114
|
-
'@typescript-eslint/no-var-requires': 'error',
|
|
115
|
-
'@typescript-eslint/no-wrapper-object-types': 'error',
|
|
116
|
-
'@typescript-eslint/object-curly-spacing': baseRules['object-curly-spacing'],
|
|
117
|
-
// '@typescript-eslint/no-throw-literal': baseRules['no-throw-literal'],
|
|
118
|
-
'@typescript-eslint/only-throw-error': baseRules['no-throw-literal'],
|
|
119
|
-
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
120
|
-
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
|
|
121
|
-
'@typescript-eslint/quotes': baseRules.quotes,
|
|
122
|
-
'@typescript-eslint/require-await': baseRules['require-await'],
|
|
123
|
-
'@typescript-eslint/return-await': baseRules['no-return-await'],
|
|
124
|
-
'@typescript-eslint/semi': baseRules.semi,
|
|
125
|
-
'@typescript-eslint/space-before-function-paren': baseRules['space-before-function-paren'],
|
|
126
|
-
'@typescript-eslint/space-infix-ops': baseRules['space-infix-ops'],
|
|
127
|
-
'@typescript-eslint/strict-boolean-expressions': [
|
|
128
|
-
'error',
|
|
129
|
-
{
|
|
130
|
-
allowNullableObject: false,
|
|
131
|
-
allowNumber: false,
|
|
132
|
-
allowString: false,
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
136
|
-
'@typescript-eslint/triple-slash-reference': 'error',
|
|
137
|
-
'@typescript-eslint/type-annotation-spacing': 'error',
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
/**
|
|
141
|
-
* JSDoc overrides
|
|
142
|
-
*/
|
|
143
|
-
{
|
|
144
|
-
rules: {
|
|
145
|
-
'jsdoc/no-types': 'error',
|
|
146
|
-
'jsdoc/require-param': 'off',
|
|
147
|
-
'jsdoc/require-param-type': 'off',
|
|
148
|
-
'jsdoc/require-returns': 'off',
|
|
149
|
-
'jsdoc/require-returns-type': 'off',
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
/**
|
|
153
|
-
* Import overrides
|
|
154
|
-
*/
|
|
155
|
-
{
|
|
156
|
-
rules: {
|
|
157
|
-
'import/extensions': [
|
|
158
|
-
baseImportRules['import/extensions'][0],
|
|
159
|
-
baseImportRules['import/extensions'][1],
|
|
160
|
-
{
|
|
161
|
-
...baseImportRules['import/extensions'][2],
|
|
162
|
-
// ts: 'never',
|
|
163
|
-
// tsx: 'never',
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
'import/no-extraneous-dependencies': [
|
|
167
|
-
baseImportRules['import/no-extraneous-dependencies'][0],
|
|
168
|
-
{
|
|
169
|
-
...baseImportRules['import/no-extraneous-dependencies'][1],
|
|
170
|
-
devDependencies: baseImportRules['import/no-extraneous-dependencies'][1].devDependencies.reduce(
|
|
171
|
-
(result: string[], devDep: string) => {
|
|
172
|
-
const toAppend = [devDep];
|
|
173
|
-
// eslint-disable-next-line unicorn/prefer-string-replace-all
|
|
174
|
-
const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1');
|
|
175
|
-
if (devDepWithTs !== devDep) {
|
|
176
|
-
toAppend.push(devDepWithTs);
|
|
177
|
-
}
|
|
178
|
-
return [...result, ...toAppend];
|
|
179
|
-
},
|
|
180
|
-
[],
|
|
181
|
-
),
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
/**
|
|
187
|
-
* Disabled rules
|
|
188
|
-
*/
|
|
189
|
-
{
|
|
190
|
-
// https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
|
|
191
|
-
rules: {
|
|
192
|
-
'brace-style': 'off',
|
|
193
|
-
camelcase: 'off',
|
|
194
|
-
'comma-dangle': 'off',
|
|
195
|
-
'comma-spacing': 'off',
|
|
196
|
-
'constructor-super': 'off',
|
|
197
|
-
'default-param-last': 'off',
|
|
198
|
-
'dot-notation': 'off',
|
|
199
|
-
'func-call-spacing': 'off',
|
|
200
|
-
'getter-return': 'off',
|
|
201
|
-
'import/default': duplicateTSC,
|
|
202
|
-
'import/export': ESLintConfig.fixme('error'), // https://github.com/benmosher/eslint-plugin-import/issues/1964
|
|
203
|
-
'import/named': duplicateTSC,
|
|
204
|
-
'import/namespace': duplicateTSC,
|
|
205
|
-
'import/no-named-as-default-member': duplicateTSC,
|
|
206
|
-
'import/no-unresolved': duplicateTSC,
|
|
207
|
-
indent: 'off',
|
|
208
|
-
'keyword-spacing': 'off',
|
|
209
|
-
'lines-between-class-members': 'off',
|
|
210
|
-
'no-array-constructor': 'off',
|
|
211
|
-
'no-const-assign': 'off',
|
|
212
|
-
'no-dupe-args': 'off',
|
|
213
|
-
'no-dupe-class-members': 'off',
|
|
214
|
-
'no-dupe-keys': 'off',
|
|
215
|
-
'no-empty-function': 'off',
|
|
216
|
-
'no-extra-parens': 'off',
|
|
217
|
-
'no-extra-semi': 'off',
|
|
218
|
-
'no-func-assign': 'off',
|
|
219
|
-
'no-implied-eval': 'off',
|
|
220
|
-
'no-import-assign': 'off',
|
|
221
|
-
'no-inner-declarations': ESLintConfig.fixme('error'), // https://github.com/typescript-eslint/typescript-eslint/issues/239
|
|
222
|
-
'no-loop-func': 'off',
|
|
223
|
-
'no-loss-of-precision': 'off',
|
|
224
|
-
'no-magic-numbers': 'off',
|
|
225
|
-
'no-new-func': 'off',
|
|
226
|
-
'no-new-symbol': 'off',
|
|
227
|
-
'no-obj-calls': 'off',
|
|
228
|
-
'no-redeclare': 'off',
|
|
229
|
-
'no-return-await': 'off',
|
|
230
|
-
'no-setter-return': 'off',
|
|
231
|
-
'no-shadow': 'off',
|
|
232
|
-
'no-this-before-super': 'off',
|
|
233
|
-
'no-throw-literal': 'off',
|
|
234
|
-
'no-undef': 'off',
|
|
235
|
-
'no-unreachable': 'off',
|
|
236
|
-
'no-unsafe-negation': 'off',
|
|
237
|
-
'no-unused-expressions': 'off',
|
|
238
|
-
'no-unused-vars': 'off',
|
|
239
|
-
'no-use-before-define': 'off',
|
|
240
|
-
'no-useless-constructor': 'off',
|
|
241
|
-
'no-var': 'error',
|
|
242
|
-
'object-curly-spacing': 'off',
|
|
243
|
-
'prefer-const': 'error',
|
|
244
|
-
'prefer-rest-params': 'error',
|
|
245
|
-
'prefer-spread': 'error',
|
|
246
|
-
quotes: 'off',
|
|
247
|
-
'require-await': 'off',
|
|
248
|
-
semi: 'off',
|
|
249
|
-
'space-before-function-paren': 'off',
|
|
250
|
-
'space-infix-ops': 'off',
|
|
251
|
-
'valid-typeof': 'off',
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
);
|
|
255
|
-
export = config;
|