@w5s/eslint-config 2.4.5 → 3.0.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/dist/index.cjs +4199 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8054 -0
- package/dist/index.d.ts +8054 -3
- package/dist/index.js +4171 -22
- package/dist/index.js.map +1 -0
- package/package.json +25 -16
- 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/config/ts.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/* eslint-disable ts/no-non-null-assertion */
|
|
2
|
+
import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
|
|
3
|
+
import { StylisticConfig, type PluginOptionsBase, type Config } from '../type.js';
|
|
4
|
+
import type { RuleOptions } from '../typegen/ts.js';
|
|
5
|
+
import { createRules } from './createRules.js';
|
|
6
|
+
|
|
7
|
+
const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['typescript', 'typescriptreact']))}`];
|
|
8
|
+
|
|
9
|
+
export async function ts(options: ts.Options = {}) {
|
|
10
|
+
const [tsPlugin, tsParser] = await Promise.all([
|
|
11
|
+
interopDefault(import('@typescript-eslint/eslint-plugin')),
|
|
12
|
+
interopDefault(import('@typescript-eslint/parser')),
|
|
13
|
+
] as const);
|
|
14
|
+
const tsRecommendedRules = tsPlugin.configs['eslint-recommended']!.overrides![0]!.rules!;
|
|
15
|
+
const tsStrictRules = tsPlugin.configs['strict']!.rules!;
|
|
16
|
+
const tsTypeCheckedRules = tsPlugin.configs['recommended-type-checked-only']!.rules!;
|
|
17
|
+
const { files = defaultFiles, rules = {}, stylistic = true, typeChecked = false } = options;
|
|
18
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
19
|
+
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
name: 'w5s/ts/setup',
|
|
23
|
+
plugins: {
|
|
24
|
+
ts: tsPlugin,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
files,
|
|
29
|
+
languageOptions: {
|
|
30
|
+
parser: tsParser,
|
|
31
|
+
parserOptions: {
|
|
32
|
+
sourceType: 'module',
|
|
33
|
+
// extraFileExtensions: componentExts.map(ext => `.${ext}`),
|
|
34
|
+
// ...typeAware
|
|
35
|
+
// ? {
|
|
36
|
+
// projectService: {
|
|
37
|
+
// allowDefaultProject: ['./*.js'],
|
|
38
|
+
// defaultProject: tsconfigPath,
|
|
39
|
+
// },
|
|
40
|
+
// tsconfigRootDir: process.cwd(),
|
|
41
|
+
// }
|
|
42
|
+
// : {},
|
|
43
|
+
// ...parserOptions as any,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
name: 'w5s/ts/rules',
|
|
47
|
+
rules: {
|
|
48
|
+
...ESLintConfig.renameRules(
|
|
49
|
+
tsRecommendedRules,
|
|
50
|
+
{ '@typescript-eslint': 'ts' },
|
|
51
|
+
),
|
|
52
|
+
...ESLintConfig.renameRules(
|
|
53
|
+
tsStrictRules,
|
|
54
|
+
{ '@typescript-eslint': 'ts' },
|
|
55
|
+
),
|
|
56
|
+
'ts/ban-ts-comment': [
|
|
57
|
+
'warn',
|
|
58
|
+
{
|
|
59
|
+
'minimumDescriptionLength': 3,
|
|
60
|
+
'ts-check': false,
|
|
61
|
+
'ts-expect-error': 'allow-with-description',
|
|
62
|
+
'ts-ignore': 'allow-with-description',
|
|
63
|
+
'ts-nocheck': true,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
'ts/no-empty-object-type': 'off',
|
|
67
|
+
'ts/no-explicit-any': 'off', // if any is explicit then it's wanted
|
|
68
|
+
'ts/no-namespace': 'off', // We don't agree with community, namespaces are great and not deprecated
|
|
69
|
+
...createRules('ts/'),
|
|
70
|
+
...(stylisticEnabled
|
|
71
|
+
? {}
|
|
72
|
+
: {}),
|
|
73
|
+
...rules,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
...(typeChecked
|
|
77
|
+
? [{
|
|
78
|
+
files: defaultFiles,
|
|
79
|
+
// ignores: ignoresTypeAware,
|
|
80
|
+
name: 'w5s/ts/rules-type-checked',
|
|
81
|
+
rules: {
|
|
82
|
+
...ESLintConfig.renameRules(
|
|
83
|
+
tsTypeCheckedRules,
|
|
84
|
+
{ '@typescript-eslint': 'ts' },
|
|
85
|
+
),
|
|
86
|
+
},
|
|
87
|
+
}] as const
|
|
88
|
+
: []),
|
|
89
|
+
] as ([Config, Config] | [Config, Config, Config]) satisfies Array<Config>;
|
|
90
|
+
}
|
|
91
|
+
export namespace ts {
|
|
92
|
+
export type Rules = RuleOptions;
|
|
93
|
+
|
|
94
|
+
export interface Options extends PluginOptionsBase<Rules> {
|
|
95
|
+
typeChecked?: boolean;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { interopDefault } from '@w5s/dev';
|
|
2
|
+
import { StylisticConfig, type Config, type PluginOptionsBase } from '../type.js';
|
|
3
|
+
import type { RuleOptions } from '../typegen/unicorn.js';
|
|
4
|
+
|
|
5
|
+
export async function unicorn(options: unicorn.Options = {}) {
|
|
6
|
+
const [unicornPlugin] = await Promise.all([
|
|
7
|
+
interopDefault(import('eslint-plugin-unicorn')),
|
|
8
|
+
] as const);
|
|
9
|
+
const { rules = {}, stylistic = true } = options;
|
|
10
|
+
const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
|
|
11
|
+
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
name: 'w5s/unicorn/setup',
|
|
15
|
+
plugins: {
|
|
16
|
+
unicorn: unicornPlugin,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'w5s/unicorn/rules',
|
|
21
|
+
rules: {
|
|
22
|
+
...(unicornPlugin.configs.recommended?.rules),
|
|
23
|
+
// Disabled for safety
|
|
24
|
+
'unicorn/consistent-destructuring': 'off',
|
|
25
|
+
'unicorn/consistent-function-scoping': 'off', // Too many false positive
|
|
26
|
+
'unicorn/filename-case': 'off',
|
|
27
|
+
'unicorn/import-index': 'off', // Not playing well with ES Module
|
|
28
|
+
'unicorn/new-for-builtins': 'off', // error, @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/122
|
|
29
|
+
'unicorn/no-array-callback-reference': 'off', // Many false positive reported
|
|
30
|
+
'unicorn/no-array-for-each': 'off', // This rule could change browser compatibility
|
|
31
|
+
'unicorn/no-array-method-this-argument': 'off', // Many false positive reported
|
|
32
|
+
'unicorn/no-array-reduce': 'off', // Array#reduce can be used
|
|
33
|
+
'unicorn/no-console-spaces': 'off',
|
|
34
|
+
'unicorn/no-fn-reference-in-iterator': 'off', // error ?
|
|
35
|
+
'unicorn/no-nested-ternary': 'off',
|
|
36
|
+
'unicorn/no-null': 'off', // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/612
|
|
37
|
+
'unicorn/no-object-as-default-parameter': 'off',
|
|
38
|
+
'unicorn/no-process-exit': 'off',
|
|
39
|
+
'unicorn/no-unreadable-array-destructuring': 'off',
|
|
40
|
+
'unicorn/no-unused-properties': 'warn',
|
|
41
|
+
'unicorn/no-useless-undefined': 'off',
|
|
42
|
+
'unicorn/prefer-add-event-listener': 'off',
|
|
43
|
+
'unicorn/prefer-default-parameters': 'off',
|
|
44
|
+
'unicorn/prefer-set-has': 'off',
|
|
45
|
+
'unicorn/prevent-abbreviations': 'off', // This rule is so dangerous : it potentially break code while fixing in many cases !!
|
|
46
|
+
'unicorn/throw-new-error': 'off', // Creating errors with call signature is OK
|
|
47
|
+
...(stylisticEnabled
|
|
48
|
+
? {}
|
|
49
|
+
: {}),
|
|
50
|
+
...rules,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
// TODO: move to another file ?
|
|
54
|
+
{
|
|
55
|
+
name: 'w5s/unicorn/overrides',
|
|
56
|
+
files: ['**/*.config.cjs', '**/*.config.js'],
|
|
57
|
+
rules: {
|
|
58
|
+
'unicorn/prefer-module': 'off',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
] as [Config, Config, Config] satisfies Array<Config>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export namespace unicorn {
|
|
65
|
+
export type Rules = RuleOptions;
|
|
66
|
+
|
|
67
|
+
export interface Options extends PluginOptionsBase<Rules> {}
|
|
68
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* eslint-disable ts/no-non-null-assertion */
|
|
2
|
+
import { interopDefault, Project } from '@w5s/dev';
|
|
3
|
+
import { StylisticConfig, type Config, type PluginOptionsBase } from '../type.js';
|
|
4
|
+
import type { RuleOptions } from '../typegen/yml.js';
|
|
5
|
+
|
|
6
|
+
const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['yaml']))}`];
|
|
7
|
+
|
|
8
|
+
export async function yml(options: yml.Options = {}) {
|
|
9
|
+
const [ymlPlugin, ymlParser] = await Promise.all([
|
|
10
|
+
interopDefault(import('eslint-plugin-yml')),
|
|
11
|
+
interopDefault(import('yaml-eslint-parser')),
|
|
12
|
+
] as const);
|
|
13
|
+
const { files = defaultFiles, rules = {}, stylistic = true } = options;
|
|
14
|
+
const { enabled: stylisticEnabled, indent, quotes } = StylisticConfig.from(stylistic);
|
|
15
|
+
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
name: 'w5s/yml/setup',
|
|
19
|
+
plugins: {
|
|
20
|
+
yml: ymlPlugin,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
files,
|
|
25
|
+
languageOptions: {
|
|
26
|
+
parser: ymlParser,
|
|
27
|
+
},
|
|
28
|
+
name: 'w5s/yml/rules',
|
|
29
|
+
rules: {
|
|
30
|
+
...(ymlPlugin.configs['flat/recommended'][0]!.rules),
|
|
31
|
+
...(ymlPlugin.configs['flat/recommended'][1]!.rules),
|
|
32
|
+
...(ymlPlugin.configs['flat/recommended'][2]!.rules),
|
|
33
|
+
...(stylisticEnabled
|
|
34
|
+
? {
|
|
35
|
+
// ...(ymlPlugin.configs['flat/standard'][3]!.rules),
|
|
36
|
+
// 'yml/array-bracket-spacing': ['error', 'never'],
|
|
37
|
+
// 'yml/comma-dangle': ['error', 'never'],
|
|
38
|
+
// 'yml/comma-style': ['error', 'last'],
|
|
39
|
+
|
|
40
|
+
// 'yml/object-curly-newline': ['error', { consistent: true, multiline: true }],
|
|
41
|
+
// 'yml/object-curly-spacing': ['error', 'always'],
|
|
42
|
+
// 'yml/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
|
|
43
|
+
// 'yml/quote-props': 'error',
|
|
44
|
+
|
|
45
|
+
'style/spaced-comment': 'off', // Fix
|
|
46
|
+
|
|
47
|
+
'yml/block-mapping-question-indicator-newline': 'error',
|
|
48
|
+
'yml/block-sequence-hyphen-indicator-newline': 'error',
|
|
49
|
+
'yml/flow-mapping-curly-newline': 'error',
|
|
50
|
+
'yml/flow-mapping-curly-spacing': 'error',
|
|
51
|
+
'yml/flow-sequence-bracket-newline': 'error',
|
|
52
|
+
'yml/flow-sequence-bracket-spacing': 'error',
|
|
53
|
+
'yml/indent': ['error', indent === 'tab' ? 2 : indent],
|
|
54
|
+
'yml/key-spacing': ['error', { afterColon: true, beforeColon: false }],
|
|
55
|
+
'yml/no-tab-indent': 'error',
|
|
56
|
+
'yml/quotes': ['error', { avoidEscape: true, prefer: quotes === 'backtick' ? 'single' as const : quotes }],
|
|
57
|
+
'yml/spaced-comment': 'error',
|
|
58
|
+
}
|
|
59
|
+
: {}),
|
|
60
|
+
...rules,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
] as [Config, Config] satisfies Array<Config>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export namespace yml {
|
|
67
|
+
export type Rules = RuleOptions;
|
|
68
|
+
|
|
69
|
+
export interface Options extends PluginOptionsBase<Rules> {}
|
|
70
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './config/es.js';
|
|
2
|
+
export * from './config/ignores.js';
|
|
3
|
+
export * from './config/jsdoc.js';
|
|
4
|
+
export * from './config/jsonc.js';
|
|
5
|
+
export * from './config/imports.js';
|
|
6
|
+
export * from './config/node.js';
|
|
7
|
+
export * from './config/stylistic.js';
|
|
8
|
+
export * from './config/test.js';
|
|
9
|
+
export * from './config/ts.js';
|
|
10
|
+
export * from './config/unicorn.js';
|
|
11
|
+
export * from './config/yml.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsdoc, jsonc, ignores, imports, node, ts, yml, unicorn, stylistic, es } from './config.js';
|
|
2
|
+
import type { Config } from './type.js';
|
|
3
|
+
|
|
4
|
+
export interface DefineConfigOptions extends ignores.Options {
|
|
5
|
+
es?: boolean | es.Options;
|
|
6
|
+
import?: boolean | imports.Options;
|
|
7
|
+
jsdoc?: boolean | jsdoc.Options;
|
|
8
|
+
jsonc?: boolean | jsonc.Options;
|
|
9
|
+
node?: boolean | node.Options;
|
|
10
|
+
stylistic?: boolean | stylistic.Options;
|
|
11
|
+
ts?: boolean | ts.Options;
|
|
12
|
+
unicorn?: boolean | unicorn.Options;
|
|
13
|
+
yml?: boolean | yml.Options;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function defineConfig(options: DefineConfigOptions = {}) {
|
|
17
|
+
const stylisticOptions = typeof options.stylistic === 'boolean' ? { enabled: options.stylistic } : { enabled: true, ...options.stylistic };
|
|
18
|
+
const withDefaultStylistic = <T>(options: T) => ({ stylistic: stylisticOptions, ...options });
|
|
19
|
+
const toOption = <T extends {}>(optionsOrBoolean: T | boolean | undefined) => withDefaultStylistic((typeof optionsOrBoolean === 'boolean' ? { enabled: optionsOrBoolean } : ({ enabled: true, ...optionsOrBoolean })) as T & { enabled: boolean });
|
|
20
|
+
const esOptions = toOption(options.es);
|
|
21
|
+
const importOptions = toOption(options.import);
|
|
22
|
+
const jsdocOptions = toOption(options.jsdoc);
|
|
23
|
+
const jsoncOptions = toOption(options.jsonc);
|
|
24
|
+
const nodeOptions = toOption(options.node);
|
|
25
|
+
const tsOptions = toOption(options.ts);
|
|
26
|
+
const unicornOptions = toOption(options.unicorn);
|
|
27
|
+
const ymlOptions = toOption(options.yml);
|
|
28
|
+
|
|
29
|
+
const returnValue: Array<Promise<Array<Config>>> = [];
|
|
30
|
+
const append = (config: Promise<ReadonlyArray<any>>) => {
|
|
31
|
+
returnValue.push(config as any);
|
|
32
|
+
};
|
|
33
|
+
append(es(esOptions));
|
|
34
|
+
append(ignores(options));
|
|
35
|
+
|
|
36
|
+
if (jsoncOptions.enabled) {
|
|
37
|
+
append(jsonc(jsoncOptions));
|
|
38
|
+
}
|
|
39
|
+
if (jsdocOptions.enabled) {
|
|
40
|
+
append(jsdoc(jsdocOptions));
|
|
41
|
+
}
|
|
42
|
+
if (stylisticOptions.enabled) {
|
|
43
|
+
append(stylistic(stylisticOptions));
|
|
44
|
+
}
|
|
45
|
+
if (importOptions.enabled) {
|
|
46
|
+
append(imports(importOptions));
|
|
47
|
+
}
|
|
48
|
+
if (nodeOptions.enabled) {
|
|
49
|
+
append(node(nodeOptions));
|
|
50
|
+
}
|
|
51
|
+
if (tsOptions.enabled) {
|
|
52
|
+
append(ts(tsOptions));
|
|
53
|
+
}
|
|
54
|
+
if (ymlOptions.enabled) {
|
|
55
|
+
append(yml(ymlOptions));
|
|
56
|
+
}
|
|
57
|
+
if (unicornOptions.enabled) {
|
|
58
|
+
append(unicorn(unicornOptions));
|
|
59
|
+
}
|
|
60
|
+
const nested = await Promise.all(returnValue);
|
|
61
|
+
return nested.reduce((acc, curr) => [...acc, ...curr], [] as Array<Config>);
|
|
62
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import esConfig from './es.js';
|
|
5
|
-
import typescriptConfig from './typescript.js';
|
|
6
|
-
import jestConfig from './jest.js';
|
|
7
|
-
import jsonConfig from './json.js';
|
|
8
|
-
import ymlConfig from './yml.js';
|
|
9
|
-
|
|
10
|
-
function tryResolve(name: string) {
|
|
11
|
-
try {
|
|
12
|
-
require.resolve(name);
|
|
13
|
-
return true;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const config: eslint.Linter.Config = ESLintConfig.concat(
|
|
20
|
-
ignoreConfig,
|
|
21
|
-
esConfig,
|
|
22
|
-
tryResolve('typescript') ? typescriptConfig : {},
|
|
23
|
-
jestConfig,
|
|
24
|
-
jsonConfig,
|
|
25
|
-
ymlConfig,
|
|
26
|
-
{
|
|
27
|
-
root: true,
|
|
28
|
-
},
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
export = config;
|
|
1
|
+
export * from './defineConfig.js';
|
|
2
|
+
export * from './config.js';
|
|
3
|
+
export { defineConfig as default } from './defineConfig.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
import type { StylisticParameters } from './StylisticConfig.js';
|
|
3
|
+
|
|
4
|
+
export interface PluginOptionsBase<Rules> {
|
|
5
|
+
files?: Linter.Config['files'];
|
|
6
|
+
/**
|
|
7
|
+
* Plugin rules
|
|
8
|
+
*/
|
|
9
|
+
rules?: Rules;
|
|
10
|
+
/**
|
|
11
|
+
* Stylistic options
|
|
12
|
+
*/
|
|
13
|
+
stylistic?: boolean | StylisticParameters;
|
|
14
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { StylisticCustomizeOptions } from '@stylistic/eslint-plugin';
|
|
2
|
+
import prettierConfig from '@w5s/prettier-config';
|
|
3
|
+
|
|
4
|
+
export interface StylisticConfig {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
indent: NonNullable<StylisticCustomizeOptions['indent']>;
|
|
7
|
+
quotes: NonNullable<StylisticCustomizeOptions['quotes']>;
|
|
8
|
+
jsx: NonNullable<StylisticCustomizeOptions['jsx']>;
|
|
9
|
+
semi: NonNullable<StylisticCustomizeOptions['semi']>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface StylisticParameters extends Partial<StylisticConfig> {}
|
|
13
|
+
|
|
14
|
+
const defaultConfig = {
|
|
15
|
+
enabled: true,
|
|
16
|
+
indent: prettierConfig.tabWidth ?? 2,
|
|
17
|
+
quotes: prettierConfig.singleQuote ? 'single' : 'double',
|
|
18
|
+
jsx: true,
|
|
19
|
+
semi: prettierConfig.semi ?? true,
|
|
20
|
+
} satisfies StylisticConfig;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @namespace
|
|
24
|
+
*/
|
|
25
|
+
export const StylisticConfig = {
|
|
26
|
+
/**
|
|
27
|
+
* Default config
|
|
28
|
+
*/
|
|
29
|
+
default: defaultConfig,
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Return a new StylisticConfig from input
|
|
33
|
+
*
|
|
34
|
+
* @param input
|
|
35
|
+
*/
|
|
36
|
+
from(input: boolean | StylisticParameters): StylisticConfig {
|
|
37
|
+
return typeof input === 'boolean' ? { ...defaultConfig, enabled: input } : { ...defaultConfig, ...input };
|
|
38
|
+
},
|
|
39
|
+
};
|
package/src/type.ts
ADDED
|
File without changes
|