@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.
Files changed (88) hide show
  1. package/dist/index.d.ts +8054 -3
  2. package/dist/index.js +4171 -22
  3. package/dist/index.js.map +1 -0
  4. package/package.json +26 -17
  5. package/src/config/createRules.ts +5 -0
  6. package/src/config/es.ts +58 -0
  7. package/src/config/ignores.ts +84 -0
  8. package/src/config/imports.ts +32 -0
  9. package/src/config/jsdoc.ts +53 -0
  10. package/src/config/jsonc.ts +237 -0
  11. package/src/config/node.ts +42 -0
  12. package/src/config/stylistic.ts +50 -0
  13. package/src/config/test.ts +44 -0
  14. package/src/config/ts.ts +97 -0
  15. package/src/config/unicorn.ts +68 -0
  16. package/src/config/yml.ts +70 -0
  17. package/src/config.ts +11 -0
  18. package/src/defineConfig.ts +62 -0
  19. package/src/index.ts +3 -31
  20. package/src/type/Config.ts +5 -0
  21. package/src/type/PluginOptionsBase.ts +14 -0
  22. package/src/type/StylisticConfig.ts +39 -0
  23. package/src/type.ts +3 -0
  24. package/src/typegen/.keep +0 -0
  25. package/src/typegen/import.d.ts +501 -0
  26. package/src/typegen/jsdoc.d.ts +1155 -0
  27. package/src/typegen/jsonc.d.ts +500 -0
  28. package/src/typegen/node.d.ts +529 -0
  29. package/src/typegen/style.d.ts +1637 -0
  30. package/src/typegen/test.d.ts +430 -0
  31. package/src/typegen/ts.d.ts +1872 -0
  32. package/src/typegen/unicorn.d.ts +913 -0
  33. package/src/typegen/yml.d.ts +363 -0
  34. package/dist/es.d.ts +0 -3
  35. package/dist/es.js +0 -10
  36. package/dist/jest.d.ts +0 -3
  37. package/dist/jest.js +0 -20
  38. package/dist/json.d.ts +0 -3
  39. package/dist/json.js +0 -14
  40. package/dist/rules/es/base.d.ts +0 -4
  41. package/dist/rules/es/base.js +0 -71
  42. package/dist/rules/es/import.d.ts +0 -3
  43. package/dist/rules/es/import.js +0 -74
  44. package/dist/rules/es/jsdoc.d.ts +0 -3
  45. package/dist/rules/es/jsdoc.js +0 -21
  46. package/dist/rules/es/node.d.ts +0 -3
  47. package/dist/rules/es/node.js +0 -20
  48. package/dist/rules/es/promise.d.ts +0 -3
  49. package/dist/rules/es/promise.js +0 -11
  50. package/dist/rules/es/unicorn.d.ts +0 -3
  51. package/dist/rules/es/unicorn.js +0 -72
  52. package/dist/rules/es.d.ts +0 -3
  53. package/dist/rules/es.js +0 -14
  54. package/dist/rules/ignore.d.ts +0 -3
  55. package/dist/rules/ignore.js +0 -54
  56. package/dist/rules/jest.d.ts +0 -3
  57. package/dist/rules/jest.js +0 -64
  58. package/dist/rules/jsonc.d.ts +0 -3
  59. package/dist/rules/jsonc.js +0 -183
  60. package/dist/rules/prettier.d.ts +0 -3
  61. package/dist/rules/prettier.js +0 -13
  62. package/dist/rules/typescript.d.ts +0 -3
  63. package/dist/rules/typescript.js +0 -249
  64. package/dist/rules/yml.d.ts +0 -3
  65. package/dist/rules/yml.js +0 -21
  66. package/dist/tsconfig.build.tsbuildinfo +0 -1
  67. package/dist/typescript.d.ts +0 -3
  68. package/dist/typescript.js +0 -21
  69. package/dist/yml.d.ts +0 -3
  70. package/dist/yml.js +0 -19
  71. package/src/es.ts +0 -12
  72. package/src/jest.ts +0 -18
  73. package/src/json.ts +0 -12
  74. package/src/rules/es/base.ts +0 -83
  75. package/src/rules/es/import.ts +0 -81
  76. package/src/rules/es/jsdoc.ts +0 -23
  77. package/src/rules/es/node.ts +0 -21
  78. package/src/rules/es/promise.ts +0 -12
  79. package/src/rules/es/unicorn.ts +0 -74
  80. package/src/rules/es.ts +0 -21
  81. package/src/rules/ignore.ts +0 -54
  82. package/src/rules/jest.ts +0 -68
  83. package/src/rules/jsonc.ts +0 -187
  84. package/src/rules/prettier.ts +0 -11
  85. package/src/rules/typescript.ts +0 -255
  86. package/src/rules/yml.ts +0 -22
  87. package/src/typescript.ts +0 -24
  88. package/src/yml.ts +0 -18
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const dev_1 = require("@w5s/dev");
6
- // @ts-ignore unicorn config is not typed
7
- const eslint_plugin_unicorn_1 = __importDefault(require("eslint-plugin-unicorn"));
8
- const config = dev_1.ESLintConfig.concat(eslint_plugin_unicorn_1.default.configs.recommended, {
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
- overrides: [
53
- {
54
- files: ['**/*.config.cjs', '**/*.config.js'],
55
- rules: {
56
- 'unicorn/prefer-module': 'off',
57
- },
58
- },
59
- ],
60
- rules: {
61
- 'unicorn/consistent-destructuring': 'off',
62
- 'unicorn/consistent-function-scoping': 'off', // Too many false positive
63
- 'unicorn/no-array-callback-reference': 'off', // Many false positive reported
64
- 'unicorn/no-array-for-each': 'off', // This rule could change browser compatibility
65
- 'unicorn/no-array-method-this-argument': 'off', // Many false positive reported
66
- 'unicorn/no-array-reduce': 'off', // Array#reduce can be used
67
- 'unicorn/no-object-as-default-parameter': 'off',
68
- 'unicorn/prefer-default-parameters': 'off',
69
- 'unicorn/prevent-abbreviations': 'off', // This rule is so dangerous : it potentially break code while fixing in many cases !!
70
- },
71
- });
72
- module.exports = config;
@@ -1,3 +0,0 @@
1
- import type eslint from 'eslint';
2
- declare const config: eslint.Linter.Config;
3
- export = config;
package/dist/rules/es.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const dev_1 = require("@w5s/dev");
6
- const base_js_1 = __importDefault(require("./es/base.js"));
7
- const promise_js_1 = __importDefault(require("./es/promise.js"));
8
- const jsdoc_js_1 = __importDefault(require("./es/jsdoc.js"));
9
- const import_js_1 = __importDefault(require("./es/import.js"));
10
- const unicorn_js_1 = __importDefault(require("./es/unicorn.js"));
11
- const node_js_1 = __importDefault(require("./es/node.js"));
12
- // import prettierConfig from './prettier.js';
13
- const config = dev_1.ESLintConfig.concat(base_js_1.default, promise_js_1.default, jsdoc_js_1.default, import_js_1.default, unicorn_js_1.default, node_js_1.default);
14
- module.exports = config;
@@ -1,3 +0,0 @@
1
- import type eslint from 'eslint';
2
- declare const config: eslint.Linter.Config;
3
- export = config;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const node_fs_1 = require("node:fs");
6
- const node_path_1 = __importDefault(require("node:path"));
7
- const node_process_1 = __importDefault(require("node:process"));
8
- const find_up_1 = __importDefault(require("find-up"));
9
- const parse_gitignore_1 = __importDefault(require("parse-gitignore"));
10
- const getGitignore = (prefix = '') => {
11
- const cwd = node_process_1.default.cwd();
12
- const gitIgnoreFile = find_up_1.default.sync(node_path_1.default.join(prefix, '.gitignore'), { cwd });
13
- if (gitIgnoreFile != null) {
14
- // eslint-disable-next-line n/no-sync
15
- const { patterns } = parse_gitignore_1.default.parse((0, node_fs_1.readFileSync)(gitIgnoreFile));
16
- const returnValue = patterns.map((pattern) => node_path_1.default.join(prefix, pattern));
17
- return returnValue;
18
- }
19
- return [];
20
- };
21
- const config = {
22
- ignorePatterns: [
23
- '!.*',
24
- '.docusaurus',
25
- '.yarn',
26
- '.common/',
27
- '.config/package-lock.json',
28
- '.config/yarn.lock',
29
- '.git/',
30
- '.go/',
31
- '.modules/',
32
- '.pnpm-store/',
33
- '.venv/',
34
- 'deprecated/',
35
- 'angular.json',
36
- 'esbuild.js',
37
- 'package-lock.json',
38
- 'pnpm-lock.yaml',
39
- 'slim.report.json',
40
- 'test-output/',
41
- 'venv/',
42
- 'yarn.lock',
43
- '_generated_/',
44
- '**/vendor/**',
45
- '**/vendors/**',
46
- '*.min.*',
47
- '*.toml',
48
- '*.timestamp-*.mjs', // esbuild/vite temporary files
49
- ...getGitignore(),
50
- ...getGitignore('android'),
51
- ...getGitignore('ios'),
52
- ],
53
- };
54
- module.exports = config;
@@ -1,3 +0,0 @@
1
- import type eslint from 'eslint';
2
- declare const config: eslint.Linter.Config;
3
- export = config;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- const dev_1 = require("@w5s/dev");
3
- const config = dev_1.ESLintConfig.concat({
4
- env: {
5
- 'jest/globals': true,
6
- },
7
- extends: ['plugin:jest/recommended'],
8
- globals: {
9
- context: true,
10
- },
11
- plugins: ['jest'],
12
- rules: {
13
- 'jest/consistent-test-it': 'error',
14
- 'jest/expect-expect': 'off', // Disabled because it does not handle functions that does the expect
15
- 'jest/no-alias-methods': 'error',
16
- 'jest/prefer-spy-on': 'error',
17
- 'jest/prefer-to-contain': 'error',
18
- 'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
19
- },
20
- settings: {
21
- jest: {
22
- // Compatibility with mocha, cypress, etc.
23
- globalAliases: {
24
- describe: ['context'],
25
- fdescribe: ['fcontext'],
26
- xdescribe: ['xcontext'],
27
- },
28
- version: 'latest',
29
- },
30
- },
31
- },
32
- // NodeJS loose config
33
- {
34
- rules: {
35
- 'n/no-sync': 'off',
36
- },
37
- },
38
- /**
39
- * Unicorn less strict to help writing tests
40
- */
41
- {
42
- rules: {
43
- 'unicorn/consistent-function-scoping': 'off',
44
- 'unicorn/no-useless-undefined': 'off',
45
- 'unicorn/prefer-module': 'off',
46
- },
47
- },
48
- /**
49
- * Typescript config is set to be less strict because we often have "hack", "mock" in tests
50
- */
51
- {
52
- rules: {
53
- '@typescript-eslint/dot-notation': dev_1.ESLintConfig.fixme(undefined), // eslint-plugin-jest seems to break this rule
54
- '@typescript-eslint/naming-convention': 'off',
55
- '@typescript-eslint/no-non-null-assertion': 'off',
56
- '@typescript-eslint/no-unsafe-assignment': 'off',
57
- '@typescript-eslint/no-unsafe-call': 'off',
58
- '@typescript-eslint/no-unsafe-member-access': 'off',
59
- '@typescript-eslint/no-unsafe-return': 'off',
60
- '@typescript-eslint/restrict-template-expressions': 'off',
61
- '@typescript-eslint/unbound-method': 'off',
62
- },
63
- });
64
- module.exports = config;
@@ -1,3 +0,0 @@
1
- import type eslint from 'eslint';
2
- declare const config: eslint.Linter.Config;
3
- export = config;
@@ -1,183 +0,0 @@
1
- "use strict";
2
- // https://github.com/keithamus/sort-package-json/blob/master/defaultRules.md
3
- const config = {
4
- extends: ['plugin:jsonc/recommended-with-jsonc', 'plugin:jsonc/prettier'],
5
- overrides: [
6
- {
7
- files: ['tsconfig*.json'],
8
- rules: {
9
- 'jsonc/sort-keys': [
10
- 'error',
11
- {
12
- order: ['$schema', 'display', 'extends', 'compilerOptions', 'include', 'exclude', 'files', 'references'],
13
- pathPattern: '^$',
14
- },
15
- {
16
- order: { type: 'asc' },
17
- pathPattern: '.*',
18
- },
19
- ],
20
- },
21
- },
22
- {
23
- files: ['package.json'],
24
- rules: {
25
- 'jsonc/sort-keys': [
26
- 'error',
27
- {
28
- order: [
29
- '$schema',
30
- 'name',
31
- 'displayName',
32
- 'version',
33
- 'private',
34
- 'description',
35
- 'categories',
36
- 'keywords',
37
- 'homepage',
38
- 'bugs',
39
- 'repository',
40
- 'funding',
41
- 'license',
42
- 'qna',
43
- 'author',
44
- 'maintainers', // Key order (per item): name, email, url
45
- 'contributors', // Key order (per item): name, email, url
46
- 'publisher',
47
- 'sideEffects',
48
- 'type',
49
- 'imports',
50
- 'exports',
51
- 'main',
52
- 'svelte',
53
- 'umd:main',
54
- 'jsdelivr',
55
- 'unpkg',
56
- 'module',
57
- 'source',
58
- 'jsnext:main',
59
- 'browser',
60
- 'react-native',
61
- 'types',
62
- 'typesVersions',
63
- 'typings',
64
- 'style',
65
- 'example',
66
- 'examplestyle',
67
- 'assets',
68
- 'bin',
69
- 'man',
70
- 'directories', // Key order: lib, bin, man, doc, example, test
71
- 'files', // Unique items
72
- 'workspaces',
73
- 'binary', // Key order: module_name, module_path, remote_path, package_name, host
74
- 'scripts', // Script sort
75
- 'betterScripts', // Script sort
76
- 'contributes',
77
- 'activationEvents', // Unique items
78
- 'husky', // Sorts the hooks field using git hook sort
79
- 'simple-git-hooks', // Key sort using git hook sort
80
- 'pre-commit',
81
- 'commitlint',
82
- 'lint-staged',
83
- 'config',
84
- 'nodemonConfig',
85
- 'browserify',
86
- 'babel',
87
- 'browserslist',
88
- 'xo',
89
- 'prettier', // Prettier sort
90
- 'eslintConfig', // ESLint sort
91
- 'eslintIgnore',
92
- 'npmpackagejsonlint', // Key sort (also recognizes: npmPackageJsonLintConfig, npmpkgjsonlint)
93
- 'release',
94
- 'remarkConfig',
95
- 'stylelint',
96
- 'ava',
97
- 'jest',
98
- 'mocha',
99
- 'nyc',
100
- 'tap',
101
- 'resolutions',
102
- 'dependencies',
103
- 'devDependencies',
104
- 'dependenciesMeta', // Key sort (deep)
105
- 'peerDependencies',
106
- 'peerDependenciesMeta', // Key sort (deep)
107
- 'optionalDependencies',
108
- 'bundledDependencies',
109
- 'bundleDependencies',
110
- 'extensionPack',
111
- 'extensionDependencies',
112
- 'flat',
113
- 'packageManager',
114
- 'engines',
115
- 'engineStrict',
116
- 'volta', // Key order: node, npm, yarn
117
- 'languageName',
118
- 'os',
119
- 'cpu',
120
- 'preferGlobal',
121
- 'publishConfig',
122
- 'icon',
123
- 'badges', // Key order (per item): description, url, href
124
- 'galleryBanner',
125
- 'preview',
126
- 'markdown',
127
- ],
128
- pathPattern: '^$',
129
- },
130
- {
131
- order: ['url', 'email'],
132
- pathPattern: `^bugs$`,
133
- },
134
- ...['repository', 'funding', 'license', 'author'].map((key) => ({
135
- order: ['type', 'name', 'email', 'url'],
136
- pathPattern: `^${key}$`,
137
- })),
138
- ...['scripts', 'betterScripts'].map((key) => ({
139
- order: { type: 'asc' },
140
- pathPattern: `^${key}$`,
141
- })),
142
- ...[
143
- 'bin',
144
- 'contributes',
145
- 'commitlint',
146
- 'config',
147
- 'nodemonConfig',
148
- 'browserify',
149
- 'babel',
150
- 'xo',
151
- 'release',
152
- 'remarkConfig',
153
- 'ava',
154
- 'jest',
155
- 'mocha',
156
- 'nyc',
157
- 'tap',
158
- 'resolutions',
159
- 'engines',
160
- 'engineStrict',
161
- 'preferGlobal',
162
- 'publishConfig',
163
- 'galleryBanner',
164
- ].map((key) => ({
165
- order: { type: 'asc' },
166
- pathPattern: `^${key}$`,
167
- })),
168
- {
169
- order: { type: 'asc' },
170
- pathPattern: '^(?:dev|peer|optional|bundled|extension)?[Dd]ependencies$',
171
- },
172
- {
173
- order: ['types', 'require', 'import'],
174
- pathPattern: '^exports.*$',
175
- },
176
- ],
177
- },
178
- },
179
- ],
180
- parser: 'jsonc-eslint-parser',
181
- plugins: ['jsonc'],
182
- };
183
- module.exports = config;
@@ -1,3 +0,0 @@
1
- import type eslint from 'eslint';
2
- declare const config: eslint.Linter.Config;
3
- export = config;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- const prettier_config_1 = __importDefault(require("@w5s/prettier-config"));
6
- const config = {
7
- extends: ['prettier'],
8
- plugins: ['prettier'],
9
- rules: {
10
- 'prettier/prettier': ['error', prettier_config_1.default],
11
- },
12
- };
13
- module.exports = config;
@@ -1,3 +0,0 @@
1
- import type eslint from 'eslint';
2
- declare const config: eslint.Linter.Config;
3
- export = config;