Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit cb1316d

Browse files
committed
Change prettier config
1 parent 94ac730 commit cb1316d

File tree

238 files changed

+1495
-485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

238 files changed

+1495
-485
lines changed

.eslintrc.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ module.exports = defineConfig({
55
ignorePatterns: ['src/index.js', '.eslintrc.js'],
66
env: {
77
es6: true,
8-
node: true
8+
node: true,
99
},
1010
extends: [
1111
'eslint:recommended',
1212
'plugin:@typescript-eslint/recommended',
1313
'plugin:@typescript-eslint/recommended-requiring-type-checking',
14-
'plugin:prettier/recommended'
14+
'plugin:prettier/recommended',
1515
],
1616
parser: '@typescript-eslint/parser',
1717
parserOptions: {
1818
project: ['./tsconfig.json'],
19-
warnOnUnsupportedTypeScriptVersion: false
19+
warnOnUnsupportedTypeScriptVersion: false,
2020
},
2121
plugins: ['@typescript-eslint', 'prettier'],
2222
rules: {
@@ -27,10 +27,16 @@ module.exports = defineConfig({
2727
semi: ['error', 'always'],
2828

2929
'@typescript-eslint/ban-ts-comment': 'off',
30-
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
30+
'@typescript-eslint/explicit-function-return-type': [
31+
'error',
32+
{ allowExpressions: true },
33+
],
3134
'@typescript-eslint/interface-name-prefix': 'off',
3235
'@typescript-eslint/member-ordering': 'off',
33-
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
36+
'@typescript-eslint/consistent-type-imports': [
37+
'error',
38+
{ prefer: 'type-imports' },
39+
],
3440
'@typescript-eslint/no-explicit-any': 'off',
3541
'@typescript-eslint/no-inferrable-types': 'off',
3642
'@typescript-eslint/no-non-null-assertion': 'off',
@@ -41,6 +47,9 @@ module.exports = defineConfig({
4147
'@typescript-eslint/prefer-optional-chain': 'warn',
4248
'@typescript-eslint/prefer-readonly': ['warn'],
4349
'@typescript-eslint/restrict-template-expressions': 'off',
44-
'@typescript-eslint/typedef': ['warn', { memberVariableDeclaration: true, variableDeclaration: true }]
45-
}
50+
'@typescript-eslint/typedef': [
51+
'warn',
52+
{ memberVariableDeclaration: true, variableDeclaration: true },
53+
],
54+
},
4655
});

.prettierrc.cjs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
*/
66
module.exports = {
77
plugins: [require.resolve('prettier-plugin-organize-imports')],
8-
9-
arrowParens: 'always',
10-
bracketSpacing: true,
11-
printWidth: 120,
12-
semi: true,
138
singleQuote: true,
14-
tabWidth: 2,
15-
trailingComma: 'none',
16-
useTabs: false
9+
trailingComma: 'all',
1710
};

.vscode/extensions.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "streetsidesoftware.code-spell-checker"]
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"editorconfig.editorconfig",
5+
"esbenp.prettier-vscode",
6+
"pflannery.vscode-versionlens",
7+
"streetsidesoftware.code-spell-checker"
8+
]
39
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = defineConfig({
5353
root: true,
5454
rules: {
5555
// rules...
56-
}
56+
},
5757
});
5858
```
5959

scripts/generate-rule-files.ts

Lines changed: 80 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -35,55 +35,49 @@ const PRETTIER_OPTIONS: Options = {
3535
plugins: [require.resolve('prettier-plugin-organize-imports')],
3636

3737
parser: 'typescript',
38-
arrowParens: 'always',
39-
bracketSpacing: true,
40-
printWidth: 120,
41-
semi: true,
4238
singleQuote: true,
43-
tabWidth: 2,
44-
trailingComma: 'none',
45-
useTabs: false
39+
trailingComma: 'all',
4640
};
4741

4842
const generationMap: Record<string, Plugin> = {
4943
eslint: {
5044
name: 'Eslint',
51-
rules: Object.fromEntries(new eslint.Linter().getRules().entries())
45+
rules: Object.fromEntries(new eslint.Linter().getRules().entries()),
5246
},
5347
'typescript-eslint': {
5448
name: 'TypeScript',
5549
prefix: '@typescript-eslint',
56-
rules: (eslintPluginTypeScript as Plugin).rules
50+
rules: (eslintPluginTypeScript as Plugin).rules,
5751
},
5852
jsdoc: {
5953
name: 'JSDoc',
60-
rules: (eslintPluginJSDoc as Plugin).rules
54+
rules: (eslintPluginJSDoc as Plugin).rules,
6155
},
6256
node: {
6357
name: 'Node',
64-
rules: (eslintPluginNode as Plugin).rules
58+
rules: (eslintPluginNode as Plugin).rules,
6559
},
6660
spellcheck: {
6761
name: 'Spellcheck',
68-
rules: (eslintPluginSpellcheck as Plugin).rules
62+
rules: (eslintPluginSpellcheck as Plugin).rules,
6963
},
7064
unicorn: {
7165
name: 'Unicorn',
72-
rules: (eslintPluginUnicorn as Plugin).rules
66+
rules: (eslintPluginUnicorn as Plugin).rules,
7367
},
7468
vue: {
7569
name: 'Vue',
76-
rules: (eslintPluginVue as Plugin).rules
70+
rules: (eslintPluginVue as Plugin).rules,
7771
},
7872
'vue-i18n': {
7973
name: 'VueI18n',
8074
prefix: '@intlify/vue-i18n',
81-
rules: (eslintPluginVueI18n as Plugin).rules
75+
rules: (eslintPluginVueI18n as Plugin).rules,
8276
},
8377
'vue-pug-sfc': {
8478
name: 'VuePugSfc',
85-
rules: (eslintPluginVuePugSfc as Plugin).rules
86-
}
79+
rules: (eslintPluginVuePugSfc as Plugin).rules,
80+
},
8781
};
8882

8983
// Generating rule files
@@ -106,62 +100,73 @@ async function main(): Promise<void> {
106100
try {
107101
const nestedDepth: number = ruleName.split('/').length;
108102

109-
const rulePath: string = path.resolve(ruleProviderDir, `${ruleName}.d.ts`);
110-
let ruleContent: string = `import type { RuleConfig } from '${'../'.repeat(nestedDepth)}rule-config';`;
103+
const rulePath: string = path.resolve(
104+
ruleProviderDir,
105+
`${ruleName}.d.ts`,
106+
);
107+
let ruleContent: string = `import type { RuleConfig } from '${'../'.repeat(
108+
nestedDepth,
109+
)}rule-config';`;
111110

112111
const ruleNamePascalCase: string = pascalCase(ruleName);
113112

114113
let description: string = upperCaseFirst(meta?.docs?.description ?? '');
115114
if (description.length > 0 && !description.endsWith('.')) {
116115
description += '.';
117116
}
118-
const seeDocLink: string = meta?.docs?.url ? `@see [${ruleName}](${meta.docs.url})` : '';
117+
const seeDocLink: string = meta?.docs?.url
118+
? `@see [${ruleName}](${meta.docs.url})`
119+
: '';
119120

120121
const deprecated: boolean | undefined = meta?.deprecated;
121122

122123
const schema: JSONSchema4 | JSONSchema4[] | undefined = meta?.schema;
123124
const schemaIsObject: boolean = !Array.isArray(schema);
124-
const mainSchema: JSONSchema4 | undefined = Array.isArray(schema) ? schema[0] : schema;
125+
const mainSchema: JSONSchema4 | undefined = Array.isArray(schema)
126+
? schema[0]
127+
: schema;
125128
const sideSchema: JSONSchema4 | undefined =
126-
schema && Array.isArray(schema) && schema.length > 1 ? schema[1] : undefined;
129+
schema && Array.isArray(schema) && schema.length > 1
130+
? schema[1]
131+
: undefined;
127132
const thirdSchema: JSONSchema4 | undefined =
128-
schema && Array.isArray(schema) && schema.length > 2 ? schema[2] : undefined;
133+
schema && Array.isArray(schema) && schema.length > 2
134+
? schema[2]
135+
: undefined;
129136
if (mainSchema) {
130137
if (sideSchema) {
131138
if (thirdSchema) {
132-
const ruleSetting: string = await compile(thirdSchema, `${ruleNamePascalCase}Setting`, {
133-
bannerComment: '',
134-
style: {
135-
bracketSpacing: true,
136-
printWidth: 120,
137-
semi: true,
138-
singleQuote: true,
139-
tabWidth: 2,
140-
trailingComma: 'none',
141-
useTabs: false
139+
const ruleSetting: string = await compile(
140+
thirdSchema,
141+
`${ruleNamePascalCase}Setting`,
142+
{
143+
bannerComment: '',
144+
style: {
145+
singleQuote: true,
146+
trailingComma: 'all',
147+
},
148+
unknownAny: false,
142149
},
143-
unknownAny: false
144-
});
150+
);
145151
ruleContent += `
146152
147153
/**
148154
* Setting.
149155
*/
150156
${ruleSetting}`;
151157
}
152-
const ruleConfig: string = await compile(sideSchema, `${ruleNamePascalCase}Config`, {
153-
bannerComment: '',
154-
style: {
155-
bracketSpacing: true,
156-
printWidth: 120,
157-
semi: true,
158-
singleQuote: true,
159-
tabWidth: 2,
160-
trailingComma: 'none',
161-
useTabs: false
158+
const ruleConfig: string = await compile(
159+
sideSchema,
160+
`${ruleNamePascalCase}Config`,
161+
{
162+
bannerComment: '',
163+
style: {
164+
singleQuote: true,
165+
trailingComma: 'all',
166+
},
167+
unknownAny: false,
162168
},
163-
unknownAny: false
164-
});
169+
);
165170
ruleContent += `
166171
167172
/**
@@ -170,19 +175,18 @@ ${ruleSetting}`;
170175
${ruleConfig}`;
171176
}
172177

173-
const ruleOption: string = await compile(mainSchema, `${ruleNamePascalCase}Option`, {
174-
bannerComment: '',
175-
style: {
176-
bracketSpacing: true,
177-
printWidth: 120,
178-
semi: true,
179-
singleQuote: true,
180-
tabWidth: 2,
181-
trailingComma: 'none',
182-
useTabs: false
178+
const ruleOption: string = await compile(
179+
mainSchema,
180+
`${ruleNamePascalCase}Option`,
181+
{
182+
bannerComment: '',
183+
style: {
184+
singleQuote: true,
185+
trailingComma: 'all',
186+
},
187+
unknownAny: false,
183188
},
184-
unknownAny: false
185-
});
189+
);
186190

187191
ruleContent += `
188192
@@ -199,7 +203,9 @@ export type ${ruleNamePascalCase}Options = ${
199203
? `${ruleNamePascalCase}Option`
200204
: `[${ruleNamePascalCase}Option?${
201205
sideSchema
202-
? `, ${ruleNamePascalCase}Config?${thirdSchema ? `, ${ruleNamePascalCase}Setting?` : ''}`
206+
? `, ${ruleNamePascalCase}Config?${
207+
thirdSchema ? `, ${ruleNamePascalCase}Setting?` : ''
208+
}`
203209
: ''
204210
}]`
205211
};`;
@@ -220,7 +226,9 @@ export type ${ruleNamePascalCase}Options = ${
220226
*
221227
* ${seeDocLink}
222228
*/
223-
export type ${ruleNamePascalCase}RuleConfig = RuleConfig<${mainSchema ? `${ruleNamePascalCase}Options` : '[]'}>;
229+
export type ${ruleNamePascalCase}RuleConfig = RuleConfig<${
230+
mainSchema ? `${ruleNamePascalCase}Options` : '[]'
231+
}>;
224232
225233
/**
226234
* ${description}${
@@ -254,13 +262,19 @@ export type ${ruleNamePascalCase}Options = ${
254262
if (nestedDepth > 1) {
255263
const subPath: string = rulePath.replace(/\/[\w-]+.d.ts$/, '');
256264
if (!fs.existsSync(subPath)) {
257-
fs.mkdirSync(rulePath.replace(/\/[\w-]+.d.ts$/, ''), { recursive: true });
265+
fs.mkdirSync(rulePath.replace(/\/[\w-]+.d.ts$/, ''), {
266+
recursive: true,
267+
});
258268
}
259269
}
260270
fs.writeFileSync(rulePath, ruleContent);
261271
} catch (error) {
262272
if (error instanceof Error) {
263-
console.error(`Failed to generate rule '${ruleName}' for ${name}.\n`, error.stack, '\n');
273+
console.error(
274+
`Failed to generate rule '${ruleName}' for ${name}.\n`,
275+
error.stack,
276+
'\n',
277+
);
264278
}
265279
failedRules.push(ruleName);
266280
}
@@ -270,7 +284,9 @@ export type ${ruleNamePascalCase}Options = ${
270284
const indexPath: string = path.resolve(ruleProviderDir, 'index.d.ts');
271285
let indexContent: string = Object.keys(rules)
272286
.filter((name) => !failedRules.includes(name))
273-
.map((name) => `import type { ${pascalCase(name)}Rule } from './${name}';`)
287+
.map(
288+
(name) => `import type { ${pascalCase(name)}Rule } from './${name}';`,
289+
)
274290
.join('\n');
275291

276292
indexContent += `

scripts/generate-rule.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,20 @@ function normalizeRuleProvider(provider) {
2929

3030
console.log({ ruleName, ruleProvider });
3131

32-
const ruleProviderDir = path.resolve(rulesDir, normalizeRuleProvider(ruleProvider));
32+
const ruleProviderDir = path.resolve(
33+
rulesDir,
34+
normalizeRuleProvider(ruleProvider),
35+
);
3336
const rulePath = path.resolve(ruleProviderDir, `${ruleName}.d.ts`);
3437

3538
/**
3639
* @param {string} name
3740
* @param {string} provider
3841
*/
3942
function generateRuleFileContent(name, provider) {
40-
const PascalCase = name.replace(/(\w)(\w*)/g, (_, g1, g2) => g1.toUpperCase() + g2.toLowerCase()).replace(/-/g, '');
43+
const PascalCase = name
44+
.replace(/(\w)(\w*)/g, (_, g1, g2) => g1.toUpperCase() + g2.toLowerCase())
45+
.replace(/-/g, '');
4146
const kebabCase = name;
4247

4348
let RuleLink = '<RuleLink>';

src/extends/eslint-plugin-import.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
*
44
* @see [Eslint import extensions](https://github.com/benmosher/eslint-plugin-import#installation)
55
*/
6-
export type ImportExtensions = 'plugin:import/errors' | 'plugin:import/warnings' | 'plugin:import/typescript';
6+
export type ImportExtensions =
7+
| 'plugin:import/errors'
8+
| 'plugin:import/warnings'
9+
| 'plugin:import/typescript';

src/extends/eslint-plugin-unicorn.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
*
44
* @see [Eslint Unicorn extensions](https://github.com/sindresorhus/eslint-plugin-unicorn)
55
*/
6-
export type UnicornExtensions = 'plugin:unicorn/recommended' | 'plugin:unicorn/all';
6+
export type UnicornExtensions =
7+
| 'plugin:unicorn/recommended'
8+
| 'plugin:unicorn/all';

src/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export interface EslintConfig {
3939
*
4040
* @see [Globals](https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals)
4141
*/
42-
globals?: Record<string, 'readonly' | 'writable' | false | 'readable' | true | 'writeable' | 'off'>;
42+
globals?: Record<
43+
string,
44+
'readonly' | 'writable' | false | 'readable' | true | 'writeable' | 'off'
45+
>;
4346
/**
4447
* Parser.
4548
*

0 commit comments

Comments
 (0)