diff --git a/README.md b/README.md
index bfb079472f..5d4e31573e 100644
--- a/README.md
+++ b/README.md
@@ -41,9 +41,9 @@ And create `eslint.config.mjs` in your project root:
```js
// eslint.config.mjs
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
-export default antfu()
+export default antfu();
```
@@ -55,10 +55,10 @@ If you still use some configs from the legacy eslintrc format, you can use the [
```js
// eslint.config.mjs
-import antfu from '@antfu/eslint-config'
-import { FlatCompat } from '@eslint/eslintrc'
+import antfu from "@antfu/eslint-config";
+import { FlatCompat } from "@eslint/eslintrc";
-const compat = new FlatCompat()
+const compat = new FlatCompat();
export default antfu(
{
@@ -68,13 +68,13 @@ export default antfu(
// Legacy config
...compat.config({
extends: [
- 'eslint:recommended',
+ "eslint:recommended",
// Other extends...
],
}),
// Other flat configs...
-)
+);
```
> Note that `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
@@ -164,16 +164,16 @@ Normally you only need to import the `antfu` preset:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
-export default antfu()
+export default antfu();
```
And that's it! Or you can configure each integration individually, for example:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
// Enable stylistic formatting rules
@@ -182,7 +182,7 @@ export default antfu({
// Or customize the stylistic rules
stylistic: {
indent: 2, // 4, or 'tab'
- quotes: 'single', // or 'double'
+ quotes: "single", // or 'double'
},
// TypeScript and Vue are auto-detected, you can also explicitly enable them:
@@ -195,17 +195,17 @@ export default antfu({
// `.eslintignore` is no longer supported in Flat config, use `ignores` instead
ignores: [
- '**/fixtures',
+ "**/fixtures",
// ...globs
],
-})
+});
```
The `antfu` factory function also accepts any number of arbitrary custom config overrides:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu(
{
@@ -215,13 +215,13 @@ export default antfu(
// From the second arguments they are ESLint Flat Configs
// you can have multiple configs
{
- files: ['**/*.ts'],
+ files: ["**/*.ts"],
rules: {},
},
{
rules: {},
},
-)
+);
```
Going more advanced, you can also import fine-grained configs and compose them as you wish:
@@ -251,7 +251,7 @@ import {
unicorn,
vue,
yaml,
-} from '@antfu/eslint-config'
+} from "@antfu/eslint-config";
export default combine(
ignores(),
@@ -268,7 +268,7 @@ export default combine(
yaml(),
toml(),
markdown(),
-)
+);
```
@@ -316,7 +316,7 @@ Certain rules would only be enabled in specific files, for example, `ts/*` rules
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu(
{
@@ -325,35 +325,35 @@ export default antfu(
},
{
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
- files: ['**/*.vue'],
+ files: ["**/*.vue"],
rules: {
- 'vue/operator-linebreak': ['error', 'before'],
+ "vue/operator-linebreak": ["error", "before"],
},
},
{
// Without `files`, they are general rules for all files
rules: {
- '@stylistic/semi': ['error', 'never'],
+ "@stylistic/semi": ["error", "never"],
},
},
-)
+);
```
We also provided the `overrides` options in each integration to make it easier:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
vue: {
overrides: {
- 'vue/operator-linebreak': ['error', 'before'],
+ "vue/operator-linebreak": ["error", "before"],
},
},
typescript: {
overrides: {
- '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
},
},
yaml: {
@@ -361,7 +361,7 @@ export default antfu({
// ...
},
},
-})
+});
```
### Config Composer
@@ -370,7 +370,7 @@ Since v2.10.0, the factory function `antfu()` returns a [`FlatConfigComposer` ob
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu()
.prepend(
@@ -378,18 +378,18 @@ export default antfu()
)
// overrides any named configs
.override(
- 'antfu/imports',
+ "antfu/imports",
{
rules: {
- 'import/order': ['error', { 'newlines-between': 'always' }],
+ "import/order": ["error", { "newlines-between": "always" }],
},
},
)
// rename plugin prefixes
.renamePlugins({
- 'old-prefix': 'new-prefix',
+ "old-prefix": "new-prefix",
// ...
- })
+ });
// ...
```
@@ -399,11 +399,11 @@ Vue support is detected automatically by checking if `vue` is installed in your
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
vue: true,
-})
+});
```
#### Vue 2
@@ -412,13 +412,13 @@ We have limited support for Vue 2 (as it's already [reached EOL](https://v2.vuej
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
vue: {
vueVersion: 2,
},
-})
+});
```
As it's in maintenance mode, we only accept bug fixes for Vue 2. It might also be removed in the future when `eslint-plugin-vue` drops support for Vue 2. We recommend upgrading to Vue 3 if possible.
@@ -433,7 +433,7 @@ Use external formatters to format files that ESLint cannot handle yet (`.css`, `
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
formatters: {
@@ -452,9 +452,9 @@ export default antfu({
* Supports Prettier and dprint
* By default uses Prettier
*/
- markdown: 'prettier',
+ markdown: "prettier",
},
-})
+});
```
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
@@ -469,11 +469,11 @@ To enable React support, you need to explicitly turn it on:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
react: true,
-})
+});
```
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
@@ -488,11 +488,11 @@ To enable svelte support, you need to explicitly turn it on:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
svelte: true,
-})
+});
```
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
@@ -507,11 +507,11 @@ To enable astro support, you need to explicitly turn it on:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
astro: true,
-})
+});
```
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
@@ -526,11 +526,11 @@ To enable Solid support, you need to explicitly turn it on:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
solid: true,
-})
+});
```
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
@@ -545,11 +545,11 @@ To enable UnoCSS support, you need to explicitly turn it on:
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
unocss: true,
-})
+});
```
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
@@ -590,7 +590,7 @@ Will be transformed to this when you hit save with your editor or run `eslint .
```ts
async function foo(msg: string): void {
- console.log(msg)
+ console.log(msg);
}
```
@@ -602,13 +602,13 @@ You can optionally enable the [type aware rules](https://typescript-eslint.io/li
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
typescript: {
- tsconfigPath: 'tsconfig.json',
+ tsconfigPath: "tsconfig.json",
},
-})
+});
```
### Editor Specific Disables
@@ -619,11 +619,11 @@ This is to prevent unused imports from getting removed by the IDE during refacto
```js
// eslint.config.js
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
isInEditor: false,
-})
+});
```
### Lint Staged
@@ -712,11 +712,11 @@ I am a very opinionated person, so as this config. I prefer the top-level functi
I know they are not necessarily the popular opinions. If you really want to get rid of them, you can disable them with:
```ts
-import antfu from '@antfu/eslint-config'
+import antfu from "@antfu/eslint-config";
export default antfu({
lessOpinionated: true,
-})
+});
```
### I prefer XXX...
diff --git a/bin/index.js b/bin/index.js
index b91240af39..8fb1272183 100755
--- a/bin/index.js
+++ b/bin/index.js
@@ -1,2 +1,2 @@
#!/usr/bin/env node
-import '../dist/cli.js'
+import "../dist/cli.js";
diff --git a/eslint.config.ts b/eslint.config.ts
index 43ff03dfcc..4cbf4c9123 100644
--- a/eslint.config.ts
+++ b/eslint.config.ts
@@ -1,5 +1,5 @@
// @ts-expect-error missing types
-import { antfu } from './src'
+import { antfu } from "./src";
export default antfu(
{
@@ -13,8 +13,8 @@ export default antfu(
},
{
ignores: [
- 'fixtures',
- '_fixtures',
+ "fixtures",
+ "_fixtures",
],
},
-)
+);
diff --git a/scripts/typegen.ts b/scripts/typegen.ts
index a34af13c7b..e8e9209a1f 100644
--- a/scripts/typegen.ts
+++ b/scripts/typegen.ts
@@ -1,6 +1,6 @@
-import fs from 'node:fs/promises'
-import { flatConfigsToRulesDTS } from 'eslint-typegen/core'
-import { builtinRules } from 'eslint/use-at-your-own-risk'
+import fs from "node:fs/promises";
+import { flatConfigsToRulesDTS } from "eslint-typegen/core";
+import { builtinRules } from "eslint/use-at-your-own-risk";
import {
astro,
combine,
@@ -26,12 +26,12 @@ import {
unocss,
vue,
yaml,
-} from '../src'
+} from "../src";
const configs = await combine(
{
plugins: {
- '': {
+ "": {
rules: Object.fromEntries(builtinRules.entries()),
},
},
@@ -59,17 +59,17 @@ const configs = await combine(
unocss(),
vue(),
yaml(),
-)
+);
-const configNames = configs.map(i => i.name).filter(Boolean) as Array
+const configNames = configs.map(i => i.name).filter(Boolean) as Array;
let dts = await flatConfigsToRulesDTS(configs, {
includeAugmentation: false,
-})
+});
dts += `
// Names of all the configs
-export type ConfigNames = ${configNames.map(i => `'${i}'`).join(' | ')}
-`
+export type ConfigNames = ${configNames.map(i => `'${i}'`).join(" | ")}
+`;
-await fs.writeFile('src/typegen.d.ts', dts)
+await fs.writeFile("src/typegen.d.ts", dts);
diff --git a/src/cli.ts b/src/cli.ts
index 27dfc0c607..898cb5da11 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -1 +1 @@
-export * from './cli/index'
+export * from "./cli/index";
diff --git a/src/cli/constants.ts b/src/cli/constants.ts
index dddaf197b9..3b92568b5e 100644
--- a/src/cli/constants.ts
+++ b/src/cli/constants.ts
@@ -1,6 +1,6 @@
-import c from 'picocolors'
+import c from "picocolors";
-import type { ExtraLibrariesOption, FrameworkOption, PromItem } from './types'
+import type { ExtraLibrariesOption, FrameworkOption, PromItem } from "./types";
export const vscodeSettingsString = `
// Enable the ESlint flat config support
@@ -54,72 +54,72 @@ export const vscodeSettingsString = `
"pcss",
"postcss"
]
-`
+`;
export const frameworkOptions: Array> = [
{
- label: c.green('Vue'),
- value: 'vue',
+ label: c.green("Vue"),
+ value: "vue",
},
{
- label: c.cyan('React'),
- value: 'react',
+ label: c.cyan("React"),
+ value: "react",
},
{
- label: c.red('Svelte'),
- value: 'svelte',
+ label: c.red("Svelte"),
+ value: "svelte",
},
{
- label: c.magenta('Astro'),
- value: 'astro',
+ label: c.magenta("Astro"),
+ value: "astro",
},
{
- label: c.cyan('Solid'),
- value: 'solid',
+ label: c.cyan("Solid"),
+ value: "solid",
},
{
- label: c.blue('Slidev'),
- value: 'slidev',
+ label: c.blue("Slidev"),
+ value: "slidev",
},
-]
+];
-export const frameworks: Array = frameworkOptions.map(({ value }) => (value))
+export const frameworks: Array = frameworkOptions.map(({ value }) => (value));
export const extraOptions: Array> = [
{
- hint: 'Use external formatters (Prettier and/or dprint) to format files that ESLint cannot handle yet (.css, .html, etc)',
- label: c.red('Formatter'),
- value: 'formatter',
+ hint: "Use external formatters (Prettier and/or dprint) to format files that ESLint cannot handle yet (.css, .html, etc)",
+ label: c.red("Formatter"),
+ value: "formatter",
},
{
- label: c.cyan('UnoCSS'),
- value: 'unocss',
+ label: c.cyan("UnoCSS"),
+ value: "unocss",
},
-]
+];
-export const extra: Array = extraOptions.map(({ value }) => (value))
+export const extra: Array = extraOptions.map(({ value }) => (value));
export const dependenciesMap = {
astro: [
- 'eslint-plugin-astro',
- 'astro-eslint-parser',
+ "eslint-plugin-astro",
+ "astro-eslint-parser",
],
react: [
- '@eslint-react/eslint-plugin',
- 'eslint-plugin-react-hooks',
- 'eslint-plugin-react-refresh',
+ "@eslint-react/eslint-plugin",
+ "eslint-plugin-react-hooks",
+ "eslint-plugin-react-refresh",
],
slidev: [
- 'prettier-plugin-slidev',
+ "prettier-plugin-slidev",
],
solid: [
- 'eslint-plugin-solid',
+ "eslint-plugin-solid",
],
svelte: [
- 'eslint-plugin-svelte',
- 'svelte-eslint-parser',
+ "eslint-plugin-svelte",
+ "svelte-eslint-parser",
],
vue: [],
-} as const
+} as const;
-export { default as pkgJson } from '../../package.json'
+export { default as pkgJson } from "../../package.json";
diff --git a/src/cli/index.ts b/src/cli/index.ts
index 38012d7e6c..1e9c5aec0f 100644
--- a/src/cli/index.ts
+++ b/src/cli/index.ts
@@ -1,58 +1,58 @@
-import process from 'node:process'
-import c from 'picocolors'
-import { hideBin } from 'yargs/helpers'
-import yargs from 'yargs'
-import * as p from '@clack/prompts'
-import { run } from './run'
-import { pkgJson } from './constants'
+import process from "node:process";
+import c from "picocolors";
+import { hideBin } from "yargs/helpers";
+import yargs from "yargs";
+import * as p from "@clack/prompts";
+import { run } from "./run";
+import { pkgJson } from "./constants";
function header() {
// eslint-disable-next-line no-console
- console.log('\n')
- p.intro(`${c.green(`@antfu/eslint-config `)}${c.dim(`v${pkgJson.version}`)}`)
+ console.log("\n");
+ p.intro(`${c.green(`@antfu/eslint-config `)}${c.dim(`v${pkgJson.version}`)}`);
}
const instance = yargs(hideBin(process.argv))
- .scriptName('@antfu/eslint-config')
- .usage('')
+ .scriptName("@antfu/eslint-config")
+ .usage("")
.command(
- '*',
- 'Run the initialization or migration',
+ "*",
+ "Run the initialization or migration",
args => args
- .option('yes', {
- alias: 'y',
- description: 'Skip prompts and use default values',
- type: 'boolean',
+ .option("yes", {
+ alias: "y",
+ description: "Skip prompts and use default values",
+ type: "boolean",
})
- .option('template', {
- alias: 't',
- description: 'Use the framework template for optimal customization: vue / react / svelte / astro',
- type: 'string',
+ .option("template", {
+ alias: "t",
+ description: "Use the framework template for optimal customization: vue / react / svelte / astro",
+ type: "string",
})
- .option('extra', {
- alias: 'e',
+ .option("extra", {
+ alias: "e",
array: true,
- description: 'Use the extra utils: formatter / perfectionist / unocss',
- type: 'string',
+ description: "Use the extra utils: formatter / perfectionist / unocss",
+ type: "string",
})
.help(),
async (args) => {
- header()
+ header();
try {
- await run(args)
+ await run(args);
}
catch (error) {
- p.log.error(c.inverse(c.red(' Failed to migrate ')))
- p.log.error(c.red(`✘ ${String(error)}`))
- process.exit(1)
+ p.log.error(c.inverse(c.red(" Failed to migrate ")));
+ p.log.error(c.red(`✘ ${String(error)}`));
+ process.exit(1);
}
},
)
.showHelpOnFail(false)
- .alias('h', 'help')
- .version('version', pkgJson.version)
- .alias('v', 'version')
+ .alias("h", "help")
+ .version("version", pkgJson.version)
+ .alias("v", "version");
instance
.help()
- .argv
+ .argv;
diff --git a/src/cli/run.ts b/src/cli/run.ts
index e10ed72c1a..c62db05ce6 100644
--- a/src/cli/run.ts
+++ b/src/cli/run.ts
@@ -1,39 +1,39 @@
-import fs from 'node:fs'
-import path from 'node:path'
-import process from 'node:process'
-import c from 'picocolors'
-import * as p from '@clack/prompts'
-
-import { extra, extraOptions, frameworkOptions, frameworks } from './constants'
-import { isGitClean } from './utils'
-import type { ExtraLibrariesOption, FrameworkOption, PromItem, PromptResult } from './types'
-import { updatePackageJson } from './stages/update-package-json'
-import { updateEslintFiles } from './stages/update-eslint-files'
-import { updateVscodeSettings } from './stages/update-vscode-settings'
+import fs from "node:fs";
+import path from "node:path";
+import process from "node:process";
+import c from "picocolors";
+import * as p from "@clack/prompts";
+
+import { extra, extraOptions, frameworkOptions, frameworks } from "./constants";
+import { isGitClean } from "./utils";
+import type { ExtraLibrariesOption, FrameworkOption, PromItem, PromptResult } from "./types";
+import { updatePackageJson } from "./stages/update-package-json";
+import { updateEslintFiles } from "./stages/update-eslint-files";
+import { updateVscodeSettings } from "./stages/update-vscode-settings";
export interface CliRunOptions {
/**
* Skip prompts and use default values
*/
- yes?: boolean
+ yes?: boolean;
/**
* Use the framework template for optimal customization: vue / react / svelte / astro
*/
- frameworks?: Array
+ frameworks?: Array;
/**
* Use the extra utils: formatter / perfectionist / unocss
*/
- extra?: Array
+ extra?: Array;
}
export async function run(options: CliRunOptions = {}) {
- const argSkipPrompt = Boolean(process.env.SKIP_PROMPT) || options.yes
- const argTemplate = options.frameworks?.map(m => m.trim()) as Array
- const argExtra = options.extra?.map(m => m.trim()) as Array
+ const argSkipPrompt = Boolean(process.env.SKIP_PROMPT) || options.yes;
+ const argTemplate = options.frameworks?.map(m => m.trim()) as Array;
+ const argExtra = options.extra?.map(m => m.trim()) as Array;
- if (fs.existsSync(path.join(process.cwd(), 'eslint.config.js'))) {
- p.log.warn(c.yellow(`eslint.config.js already exists, migration wizard exited.`))
- return process.exit(1)
+ if (fs.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
+ p.log.warn(c.yellow(`eslint.config.js already exists, migration wizard exited.`));
+ return process.exit(1);
}
// Set default value for promptResult if `argSkipPrompt` is enabled
@@ -42,76 +42,76 @@ export async function run(options: CliRunOptions = {}) {
frameworks: argTemplate ?? [],
uncommittedConfirmed: false,
updateVscodeSettings: true,
- }
+ };
if (!argSkipPrompt) {
result = await p.group({
uncommittedConfirmed: () => {
if (argSkipPrompt || isGitClean())
- return Promise.resolve(true)
+ return Promise.resolve(true);
return p.confirm({
initialValue: false,
- message: 'There are uncommitted changes in the current repository, are you sure to continue?',
- })
+ message: "There are uncommitted changes in the current repository, are you sure to continue?",
+ });
},
frameworks: ({ results }) => {
- const isArgTemplateValid = typeof argTemplate === 'string' && Boolean(frameworks.includes((argTemplate as FrameworkOption)))
+ const isArgTemplateValid = typeof argTemplate === "string" && Boolean(frameworks.includes((argTemplate as FrameworkOption)));
if (!results.uncommittedConfirmed || isArgTemplateValid)
- return
+ return;
const message = !isArgTemplateValid && argTemplate
? `"${argTemplate}" isn't a valid template. Please choose from below: `
- : 'Select a framework:'
+ : "Select a framework:";
return p.multiselect>, FrameworkOption>({
message: c.reset(message),
options: frameworkOptions,
required: false,
- })
+ });
},
extra: ({ results }) => {
- const isArgExtraValid = argExtra?.length && argExtra.filter(element => !extra.includes((element as ExtraLibrariesOption))).length === 0
+ const isArgExtraValid = argExtra?.length && argExtra.filter(element => !extra.includes((element as ExtraLibrariesOption))).length === 0;
if (!results.uncommittedConfirmed || isArgExtraValid)
- return
+ return;
const message = !isArgExtraValid && argExtra
? `"${argExtra}" isn't a valid extra util. Please choose from below: `
- : 'Select a extra utils:'
+ : "Select a extra utils:";
return p.multiselect>, ExtraLibrariesOption>({
message: c.reset(message),
options: extraOptions,
required: false,
- })
+ });
},
updateVscodeSettings: ({ results }) => {
if (!results.uncommittedConfirmed)
- return
+ return;
return p.confirm({
initialValue: true,
- message: 'Update .vscode/settings.json for better VS Code experience?',
- })
+ message: "Update .vscode/settings.json for better VS Code experience?",
+ });
},
}, {
onCancel: () => {
- p.cancel('Operation cancelled.')
- process.exit(0)
+ p.cancel("Operation cancelled.");
+ process.exit(0);
},
- }) as PromptResult
+ }) as PromptResult;
if (!result.uncommittedConfirmed)
- return process.exit(1)
+ return process.exit(1);
}
- await updatePackageJson(result)
- await updateEslintFiles(result)
- await updateVscodeSettings(result)
+ await updatePackageJson(result);
+ await updateEslintFiles(result);
+ await updateVscodeSettings(result);
- p.log.success(c.green(`Setup completed`))
- p.outro(`Now you can update the dependencies and run ${c.blue('eslint . --fix')}\n`)
+ p.log.success(c.green(`Setup completed`));
+ p.outro(`Now you can update the dependencies and run ${c.blue("eslint . --fix")}\n`);
}
diff --git a/src/cli/stages/update-eslint-files.ts b/src/cli/stages/update-eslint-files.ts
index abc513266d..095b1c91c3 100644
--- a/src/cli/stages/update-eslint-files.ts
+++ b/src/cli/stages/update-eslint-files.ts
@@ -1,70 +1,70 @@
-import fs from 'node:fs'
-import fsp from 'node:fs/promises'
-import process from 'node:process'
-import path from 'node:path'
-import c from 'picocolors'
-import * as p from '@clack/prompts'
+import fs from "node:fs";
+import fsp from "node:fs/promises";
+import process from "node:process";
+import path from "node:path";
+import c from "picocolors";
+import * as p from "@clack/prompts";
// @ts-expect-error missing types
-import parse from 'parse-gitignore'
-import { getEslintConfigContent } from '../utils'
-import type { PromptResult } from '../types'
+import parse from "parse-gitignore";
+import { getEslintConfigContent } from "../utils";
+import type { PromptResult } from "../types";
export async function updateEslintFiles(result: PromptResult) {
- const cwd = process.cwd()
- const pathESLintIgnore = path.join(cwd, '.eslintignore')
- const pathPackageJSON = path.join(cwd, 'package.json')
+ const cwd = process.cwd();
+ const pathESLintIgnore = path.join(cwd, ".eslintignore");
+ const pathPackageJSON = path.join(cwd, "package.json");
- const pkgContent = await fsp.readFile(pathPackageJSON, 'utf8')
- const pkg: Record = JSON.parse(pkgContent)
+ const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
+ const pkg: Record = JSON.parse(pkgContent);
- const configFileName = pkg.type === 'module' ? 'eslint.config.js' : 'eslint.config.mjs'
- const pathFlatConfig = path.join(cwd, configFileName)
+ const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
+ const pathFlatConfig = path.join(cwd, configFileName);
- const eslintIgnores: Array = []
+ const eslintIgnores: Array = [];
if (fs.existsSync(pathESLintIgnore)) {
- p.log.step(c.cyan(`Migrating existing .eslintignore`))
- const content = await fsp.readFile(pathESLintIgnore, 'utf8')
- const parsed = parse(content)
- const globs = parsed.globs()
+ p.log.step(c.cyan(`Migrating existing .eslintignore`));
+ const content = await fsp.readFile(pathESLintIgnore, "utf8");
+ const parsed = parse(content);
+ const globs = parsed.globs();
for (const glob of globs) {
- if (glob.type === 'ignore')
- eslintIgnores.push(...glob.patterns)
- else if (glob.type === 'unignore')
- eslintIgnores.push(...glob.patterns.map((pattern: string) => `!${pattern}`))
+ if (glob.type === "ignore")
+ eslintIgnores.push(...glob.patterns);
+ else if (glob.type === "unignore")
+ eslintIgnores.push(...glob.patterns.map((pattern: string) => `!${pattern}`));
}
}
- const configLines: Array = []
+ const configLines: Array = [];
if (eslintIgnores.length > 0)
- configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`)
+ configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
- if (result.extra.includes('formatter'))
- configLines.push(`formatters: true,`)
+ if (result.extra.includes("formatter"))
+ configLines.push(`formatters: true,`);
- if (result.extra.includes('unocss'))
- configLines.push(`unocss: true,`)
+ if (result.extra.includes("unocss"))
+ configLines.push(`unocss: true,`);
for (const framework of result.frameworks)
- configLines.push(`${framework}: true,`)
+ configLines.push(`${framework}: true,`);
- const mainConfig = configLines.map(i => ` ${i}`).join('\n')
- const additionalConfig: Array = []
+ const mainConfig = configLines.map(i => ` ${i}`).join("\n");
+ const additionalConfig: Array = [];
- const eslintConfigContent: string = getEslintConfigContent(mainConfig, additionalConfig)
+ const eslintConfigContent: string = getEslintConfigContent(mainConfig, additionalConfig);
- await fsp.writeFile(pathFlatConfig, eslintConfigContent)
- p.log.success(c.green(`Created ${configFileName}`))
+ await fsp.writeFile(pathFlatConfig, eslintConfigContent);
+ p.log.success(c.green(`Created ${configFileName}`));
- const files = fs.readdirSync(cwd)
- const legacyConfig: Array = []
+ const files = fs.readdirSync(cwd);
+ const legacyConfig: Array = [];
for (const file of files) {
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
- legacyConfig.push(file)
+ legacyConfig.push(file);
}
if (legacyConfig.length > 0)
- p.note(`${c.dim(legacyConfig.join(', '))}`, 'You can now remove those files manually')
+ p.note(`${c.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
}
diff --git a/src/cli/stages/update-package-json.ts b/src/cli/stages/update-package-json.ts
index bd10e8a1b3..fe5fbd3a29 100644
--- a/src/cli/stages/update-package-json.ts
+++ b/src/cli/stages/update-package-json.ts
@@ -1,71 +1,71 @@
-import path from 'node:path'
-import fsp from 'node:fs/promises'
-import process from 'node:process'
-import c from 'picocolors'
-import * as p from '@clack/prompts'
+import path from "node:path";
+import fsp from "node:fs/promises";
+import process from "node:process";
+import c from "picocolors";
+import * as p from "@clack/prompts";
-import { dependenciesMap, pkgJson } from '../constants'
-import type { ExtraLibrariesOption, PromptResult } from '../types'
+import { dependenciesMap, pkgJson } from "../constants";
+import type { ExtraLibrariesOption, PromptResult } from "../types";
export async function updatePackageJson(result: PromptResult) {
- const cwd = process.cwd()
+ const cwd = process.cwd();
- const pathPackageJSON = path.join(cwd, 'package.json')
+ const pathPackageJSON = path.join(cwd, "package.json");
- p.log.step(c.cyan(`Bumping @antfu/eslint-config to v${pkgJson.version}`))
+ p.log.step(c.cyan(`Bumping @antfu/eslint-config to v${pkgJson.version}`));
- const pkgContent = await fsp.readFile(pathPackageJSON, 'utf8')
- const pkg: Record = JSON.parse(pkgContent)
+ const pkgContent = await fsp.readFile(pathPackageJSON, "utf8");
+ const pkg: Record = JSON.parse(pkgContent);
- pkg.devDependencies ??= {}
- pkg.devDependencies['@antfu/eslint-config'] = `^${pkgJson.version}`
+ pkg.devDependencies ??= {};
+ pkg.devDependencies["@antfu/eslint-config"] = `^${pkgJson.version}`;
pkg.devDependencies.eslint ??= pkgJson.devDependencies.eslint
- .replace('npm:eslint-ts-patch@', '')
- .replace(/-\d+$/, '')
+ .replace("npm:eslint-ts-patch@", "")
+ .replace(/-\d+$/, "");
- const addedPackages: Array = []
+ const addedPackages: Array = [];
if (result.extra.length > 0) {
result.extra.forEach((item: ExtraLibrariesOption) => {
switch (item) {
- case 'formatter': {
+ case "formatter": {
for (const f of ([
- 'eslint-plugin-format',
- result.frameworks.includes('astro') ? 'prettier-plugin-astro' : null,
+ "eslint-plugin-format",
+ result.frameworks.includes("astro") ? "prettier-plugin-astro" : null,
] as const)) {
if (!f)
- continue
- pkg.devDependencies[f] = pkgJson.devDependencies[f]
- addedPackages.push(f)
+ continue;
+ pkg.devDependencies[f] = pkgJson.devDependencies[f];
+ addedPackages.push(f);
}
- break
+ break;
}
- case 'unocss': {
+ case "unocss": {
for (const f of ([
- '@unocss/eslint-plugin',
+ "@unocss/eslint-plugin",
] as const)) {
- pkg.devDependencies[f] = pkgJson.devDependencies[f]
- addedPackages.push(f)
+ pkg.devDependencies[f] = pkgJson.devDependencies[f];
+ addedPackages.push(f);
}
- break
+ break;
}
}
- })
+ });
}
for (const framework of result.frameworks) {
- const deps = dependenciesMap[framework]
+ const deps = dependenciesMap[framework];
if (deps) {
for (const f of deps) {
- pkg.devDependencies[f] = pkgJson.devDependencies[f]
- addedPackages.push(f)
+ pkg.devDependencies[f] = pkgJson.devDependencies[f];
+ addedPackages.push(f);
}
}
}
if (addedPackages.length > 0)
- p.note(`${c.dim(addedPackages.join(', '))}`, 'Added packages')
+ p.note(`${c.dim(addedPackages.join(", "))}`, "Added packages");
- await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2))
- p.log.success(c.green(`Changes wrote to package.json`))
+ await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
+ p.log.success(c.green(`Changes wrote to package.json`));
}
diff --git a/src/cli/stages/update-vscode-settings.ts b/src/cli/stages/update-vscode-settings.ts
index bf2c18a85f..78eff515ec 100644
--- a/src/cli/stages/update-vscode-settings.ts
+++ b/src/cli/stages/update-vscode-settings.ts
@@ -1,37 +1,37 @@
-import path from 'node:path'
-import fsp from 'node:fs/promises'
-import fs from 'node:fs'
-import process from 'node:process'
-import c from 'picocolors'
-import * as p from '@clack/prompts'
+import path from "node:path";
+import fsp from "node:fs/promises";
+import fs from "node:fs";
+import process from "node:process";
+import c from "picocolors";
+import * as p from "@clack/prompts";
-import { vscodeSettingsString } from '../constants'
-import type { PromptResult } from '../types'
+import { vscodeSettingsString } from "../constants";
+import type { PromptResult } from "../types";
export async function updateVscodeSettings(result: PromptResult) {
- const cwd = process.cwd()
+ const cwd = process.cwd();
if (!result.updateVscodeSettings)
- return
+ return;
- const dotVscodePath: string = path.join(cwd, '.vscode')
- const settingsPath: string = path.join(dotVscodePath, 'settings.json')
+ const dotVscodePath: string = path.join(cwd, ".vscode");
+ const settingsPath: string = path.join(dotVscodePath, "settings.json");
if (!fs.existsSync(dotVscodePath))
- await fsp.mkdir(dotVscodePath, { recursive: true })
+ await fsp.mkdir(dotVscodePath, { recursive: true });
if (fs.existsSync(settingsPath)) {
- let settingsContent = await fsp.readFile(settingsPath, 'utf8')
+ let settingsContent = await fsp.readFile(settingsPath, "utf8");
- settingsContent = settingsContent.trim().replace(/\s*}$/, '')
- settingsContent += settingsContent.endsWith(',') || settingsContent.endsWith('{') ? '' : ','
- settingsContent += `${vscodeSettingsString}}\n`
+ settingsContent = settingsContent.trim().replace(/\s*}$/, "");
+ settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
+ settingsContent += `${vscodeSettingsString}}\n`;
- await fsp.writeFile(settingsPath, settingsContent, 'utf-8')
- p.log.success(c.green(`Updated .vscode/settings.json`))
+ await fsp.writeFile(settingsPath, settingsContent, "utf-8");
+ p.log.success(c.green(`Updated .vscode/settings.json`));
}
else {
- await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, 'utf-8')
- p.log.success(c.green(`Created .vscode/settings.json`))
+ await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
+ p.log.success(c.green(`Created .vscode/settings.json`));
}
}
diff --git a/src/cli/types.ts b/src/cli/types.ts
index e88a6a9f63..868f5539e0 100644
--- a/src/cli/types.ts
+++ b/src/cli/types.ts
@@ -1,16 +1,16 @@
export interface PromItem {
- label: string
- value: T
- hint?: string
+ label: string;
+ value: T;
+ hint?: string;
}
-export type FrameworkOption = 'vue' | 'react' | 'svelte' | 'astro' | 'solid' | 'slidev'
+export type FrameworkOption = "vue" | "react" | "svelte" | "astro" | "solid" | "slidev";
-export type ExtraLibrariesOption = 'formatter' | 'unocss'
+export type ExtraLibrariesOption = "formatter" | "unocss";
export interface PromptResult {
- uncommittedConfirmed: boolean
- frameworks: Array
- extra: Array
- updateVscodeSettings: unknown
+ uncommittedConfirmed: boolean;
+ frameworks: Array;
+ extra: Array;
+ updateVscodeSettings: unknown;
}
diff --git a/src/cli/utils.ts b/src/cli/utils.ts
index 4a88f7b05b..11880647be 100644
--- a/src/cli/utils.ts
+++ b/src/cli/utils.ts
@@ -1,12 +1,12 @@
-import { execSync } from 'node:child_process'
+import { execSync } from "node:child_process";
export function isGitClean() {
try {
- execSync('git diff-index --quiet HEAD --')
- return true
+ execSync("git diff-index --quiet HEAD --");
+ return true;
}
catch {
- return false
+ return false;
}
}
@@ -20,5 +20,5 @@ import antfu from '@antfu/eslint-config'
export default antfu({
${mainConfig}
}${additionalConfigs?.map(config => `,{\n${config}\n}`)})
-`.trimStart()
+`.trimStart();
}
diff --git a/src/compat.ts b/src/compat.ts
index 9cff395539..d34eaee5d5 100644
--- a/src/compat.ts
+++ b/src/compat.ts
@@ -1,13 +1,13 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
-import { FlatCompat } from '@eslint/eslintrc'
-import path from 'node:path'
-import { fileURLToPath } from 'node:url'
+import { FlatCompat } from "@eslint/eslintrc";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
-const __filename = fileURLToPath(import.meta.url)
-const __dirname = path.dirname(path.join(__filename, '..'))
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(path.join(__filename, ".."));
export const compat = new FlatCompat({
baseDirectory: __dirname,
-})
+});
diff --git a/src/configs/a11y.ts b/src/configs/a11y.ts
index e9ef99144c..7a6bb8abd7 100644
--- a/src/configs/a11y.ts
+++ b/src/configs/a11y.ts
@@ -1,26 +1,26 @@
-import type { TypedFlatConfigItem } from '../types'
-import { compat } from '../compat'
+import type { TypedFlatConfigItem } from "../types";
+import { compat } from "../compat";
export function a11y(): Array {
return compat.config({
- extends: ['plugin:jsx-a11y/recommended'],
+ extends: ["plugin:jsx-a11y/recommended"],
rules: {
// @see https://github.com/vercel/next.js/blob/canary/packages/eslint-config-next/index.js
// #region jsx-a11y from nextjs eslint config
- 'jsx-a11y/alt-text': [
- 'warn',
+ "jsx-a11y/alt-text": [
+ "warn",
{
- elements: ['img'],
- img: ['Image'],
+ elements: ["img"],
+ img: ["Image"],
},
],
- 'jsx-a11y/aria-props': 'warn',
- 'jsx-a11y/aria-proptypes': 'warn',
- 'jsx-a11y/aria-unsupported-elements': 'warn',
- 'jsx-a11y/role-has-required-aria-props': 'warn',
- 'jsx-a11y/role-supports-aria-props': 'warn',
+ "jsx-a11y/aria-props": "warn",
+ "jsx-a11y/aria-proptypes": "warn",
+ "jsx-a11y/aria-unsupported-elements": "warn",
+ "jsx-a11y/role-has-required-aria-props": "warn",
+ "jsx-a11y/role-supports-aria-props": "warn",
// #endregion jsx-a11y from nextjs eslint config
},
- })
+ });
}
diff --git a/src/configs/astro.ts b/src/configs/astro.ts
index 778ac7a49a..b1ccffcd0b 100644
--- a/src/configs/astro.ts
+++ b/src/configs/astro.ts
@@ -1,6 +1,6 @@
-import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types'
-import { GLOB_ASTRO } from '../globs'
-import { interopDefault } from '../utils'
+import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from "../types";
+import { GLOB_ASTRO } from "../globs";
+import { interopDefault } from "../utils";
export async function astro(
options: OptionsOverrides & OptionsStylistic & OptionsFiles = {},
@@ -10,21 +10,21 @@ export async function astro(
overrides = {},
stylistic = true,
- } = options
+ } = options;
const [
pluginAstro,
parserAstro,
parserTs,
] = await Promise.all([
- interopDefault(import('eslint-plugin-astro')),
- interopDefault(import('astro-eslint-parser')),
- interopDefault(import('@typescript-eslint/parser')),
- ] as const)
+ interopDefault(import("eslint-plugin-astro")),
+ interopDefault(import("astro-eslint-parser")),
+ interopDefault(import("@typescript-eslint/parser")),
+ ] as const);
return [
{
- name: 'antfu/astro/setup',
+ name: "antfu/astro/setup",
plugins: {
astro: pluginAstro,
},
@@ -35,38 +35,38 @@ export async function astro(
globals: pluginAstro.environments.astro.globals,
parser: parserAstro,
parserOptions: {
- extraFileExtensions: ['.astro'],
+ extraFileExtensions: [".astro"],
parser: parserTs,
},
- sourceType: 'module',
+ sourceType: "module",
},
- name: 'antfu/astro/rules',
- processor: 'astro/client-side-ts',
+ name: "antfu/astro/rules",
+ processor: "astro/client-side-ts",
rules: {
// use recommended rules
- 'astro/missing-client-only-directive-value': 'error',
- 'astro/no-conflict-set-directives': 'error',
- 'astro/no-deprecated-astro-canonicalurl': 'error',
- 'astro/no-deprecated-astro-fetchcontent': 'error',
- 'astro/no-deprecated-astro-resolve': 'error',
- 'astro/no-deprecated-getentrybyslug': 'error',
- 'astro/no-set-html-directive': 'off',
- 'astro/no-unused-define-vars-in-style': 'error',
- 'astro/semi': 'off',
- 'astro/valid-compile': 'error',
+ "astro/missing-client-only-directive-value": "error",
+ "astro/no-conflict-set-directives": "error",
+ "astro/no-deprecated-astro-canonicalurl": "error",
+ "astro/no-deprecated-astro-fetchcontent": "error",
+ "astro/no-deprecated-astro-resolve": "error",
+ "astro/no-deprecated-getentrybyslug": "error",
+ "astro/no-set-html-directive": "off",
+ "astro/no-unused-define-vars-in-style": "error",
+ "astro/semi": "off",
+ "astro/valid-compile": "error",
...stylistic
? {
- '@stylistic/indent': 'off',
- '@stylistic/jsx-closing-tag-location': 'off',
- '@stylistic/jsx-indent': 'off',
- '@stylistic/jsx-one-expression-per-line': 'off',
- '@stylistic/no-multiple-empty-lines': 'off',
+ "@stylistic/indent": "off",
+ "@stylistic/jsx-closing-tag-location": "off",
+ "@stylistic/jsx-indent": "off",
+ "@stylistic/jsx-one-expression-per-line": "off",
+ "@stylistic/no-multiple-empty-lines": "off",
}
: {},
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/command.ts b/src/configs/command.ts
index 20703675da..a76da3a35e 100644
--- a/src/configs/command.ts
+++ b/src/configs/command.ts
@@ -1,11 +1,11 @@
-import createCommand from 'eslint-plugin-command/config'
-import type { TypedFlatConfigItem } from '../types'
+import createCommand from "eslint-plugin-command/config";
+import type { TypedFlatConfigItem } from "../types";
export async function command(): Promise> {
return [
{
...createCommand(),
- name: 'antfu/command/rules',
+ name: "antfu/command/rules",
},
- ]
+ ];
}
diff --git a/src/configs/comments.ts b/src/configs/comments.ts
index 3e6476cfaa..c5803bacb0 100644
--- a/src/configs/comments.ts
+++ b/src/configs/comments.ts
@@ -1,19 +1,19 @@
-import type { TypedFlatConfigItem } from '../types'
-import { pluginComments } from '../plugins'
+import type { TypedFlatConfigItem } from "../types";
+import { pluginComments } from "../plugins";
export async function comments(): Promise> {
return [
{
- name: 'antfu/eslint-comments/rules',
+ name: "antfu/eslint-comments/rules",
plugins: {
- 'eslint-comments': pluginComments,
+ "eslint-comments": pluginComments,
},
rules: {
- 'eslint-comments/no-aggregating-enable': 'error',
- 'eslint-comments/no-duplicate-disable': 'error',
- 'eslint-comments/no-unlimited-disable': 'error',
- 'eslint-comments/no-unused-enable': 'error',
+ "eslint-comments/no-aggregating-enable": "error",
+ "eslint-comments/no-duplicate-disable": "error",
+ "eslint-comments/no-unlimited-disable": "error",
+ "eslint-comments/no-unused-enable": "error",
},
},
- ]
+ ];
}
diff --git a/src/configs/formatters.ts b/src/configs/formatters.ts
index b97c63ba13..522a91c687 100644
--- a/src/configs/formatters.ts
+++ b/src/configs/formatters.ts
@@ -1,9 +1,9 @@
-import { isPackageExists } from 'local-pkg'
-import { GLOB_ASTRO, GLOB_CSS, GLOB_GRAPHQL, GLOB_HTML, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_XML } from '../globs'
-import type { VendoredPrettierOptions } from '../vender/prettier-types'
-import { ensurePackages, interopDefault, parserPlain } from '../utils'
-import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem } from '../types'
-import { StylisticConfigDefaults } from './stylistic'
+import { isPackageExists } from "local-pkg";
+import { GLOB_ASTRO, GLOB_CSS, GLOB_GRAPHQL, GLOB_HTML, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_XML } from "../globs";
+import type { VendoredPrettierOptions } from "../vender/prettier-types";
+import { ensurePackages, interopDefault, parserPlain } from "../utils";
+import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem } from "../types";
+import { StylisticConfigDefaults } from "./stylistic";
export async function formatters(
options: OptionsFormatters | true = {},
@@ -11,29 +11,29 @@ export async function formatters(
): Promise> {
if (options === true) {
options = {
- astro: isPackageExists('astro'),
+ astro: isPackageExists("astro"),
css: true,
graphql: true,
html: true,
markdown: true,
- slidev: isPackageExists('@slidev/cli'),
- tailwindcss: isPackageExists('tailwindcss'),
- xml: isPackageExists('@prettier/plugin-xml'),
- }
+ slidev: isPackageExists("@slidev/cli"),
+ tailwindcss: isPackageExists("tailwindcss"),
+ xml: isPackageExists("@prettier/plugin-xml"),
+ };
}
await ensurePackages([
- 'eslint-plugin-format',
- '@trivago/prettier-plugin-sort-imports',
- 'prettier-plugin-packagejson',
- options.tailwindcss ? 'prettier-plugin-tailwindcss' : undefined,
- options.markdown && options.slidev ? 'prettier-plugin-slidev' : undefined,
- options.astro ? 'prettier-plugin-astro' : undefined,
- options.xml ? '@prettier/plugin-xml' : undefined,
- ])
+ "eslint-plugin-format",
+ "@trivago/prettier-plugin-sort-imports",
+ "prettier-plugin-packagejson",
+ options.tailwindcss ? "prettier-plugin-tailwindcss" : undefined,
+ options.markdown && options.slidev ? "prettier-plugin-slidev" : undefined,
+ options.astro ? "prettier-plugin-astro" : undefined,
+ options.xml ? "@prettier/plugin-xml" : undefined,
+ ]);
- if (options.slidev && options.markdown !== true && options.markdown !== 'prettier')
- throw new Error('`slidev` option only works when `markdown` is enabled with `prettier`')
+ if (options.slidev && options.markdown !== true && options.markdown !== "prettier")
+ throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
const {
indent,
@@ -42,46 +42,46 @@ export async function formatters(
} = {
...StylisticConfigDefaults,
...stylistic,
- }
+ };
const prettierOptions: VendoredPrettierOptions = Object.assign(
{
- endOfLine: 'auto',
+ endOfLine: "auto",
semi,
- singleQuote: quotes === 'single',
- tabWidth: typeof indent === 'number' ? indent : 2,
- trailingComma: 'all',
- useTabs: indent === 'tab',
+ singleQuote: quotes === "single",
+ tabWidth: typeof indent === "number" ? indent : 2,
+ trailingComma: "all",
+ useTabs: indent === "tab",
} satisfies VendoredPrettierOptions,
options.prettierOptions || {},
- )
+ );
const prettierXmlOptions = {
- xmlQuoteAttributes: 'double',
+ xmlQuoteAttributes: "double",
xmlSelfClosingSpace: true,
xmlSortAttributesByKey: false,
- xmlWhitespaceSensitivity: 'ignore',
- }
+ xmlWhitespaceSensitivity: "ignore",
+ };
const dprintOptions = Object.assign(
{
- indentWidth: typeof indent === 'number' ? indent : 2,
- quoteStyle: quotes === 'single' ? 'preferSingle' : 'preferDouble',
- useTabs: indent === 'tab',
+ indentWidth: typeof indent === "number" ? indent : 2,
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
+ useTabs: indent === "tab",
},
options.dprintOptions || {},
- )
+ );
- const pluginFormat = await interopDefault(import('eslint-plugin-format'))
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
const configs: Array = [
{
- name: 'antfu/formatter/setup',
+ name: "antfu/formatter/setup",
plugins: {
format: pluginFormat,
},
},
- ]
+ ];
if (options.css) {
configs.push(
@@ -90,13 +90,13 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/css',
+ name: "antfu/formatter/css",
rules: {
- 'format/prettier': [
- 'error',
+ "format/prettier": [
+ "error",
{
...prettierOptions,
- parser: 'css',
+ parser: "css",
},
],
},
@@ -106,13 +106,13 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/scss',
+ name: "antfu/formatter/scss",
rules: {
- 'format/prettier': [
- 'error',
+ "format/prettier": [
+ "error",
{
...prettierOptions,
- parser: 'scss',
+ parser: "scss",
},
],
},
@@ -122,18 +122,18 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/less',
+ name: "antfu/formatter/less",
rules: {
- 'format/prettier': [
- 'error',
+ "format/prettier": [
+ "error",
{
...prettierOptions,
- parser: 'less',
+ parser: "less",
},
],
},
},
- )
+ );
}
if (options.html) {
@@ -142,17 +142,17 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/html',
+ name: "antfu/formatter/html",
rules: {
- 'format/prettier': [
- 'error',
+ "format/prettier": [
+ "error",
{
...prettierOptions,
- parser: 'html',
+ parser: "html",
},
],
},
- })
+ });
}
if (options.xml) {
@@ -161,33 +161,33 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/xml',
+ name: "antfu/formatter/xml",
rules: {
- 'format/prettier': [
- 'error',
+ "format/prettier": [
+ "error",
{
...prettierXmlOptions,
...prettierOptions,
- parser: 'xml',
+ parser: "xml",
plugins: [
- '@prettier/plugin-xml',
+ "@prettier/plugin-xml",
],
},
],
},
- })
+ });
}
if (options.markdown) {
const formater = options.markdown === true
- ? 'prettier'
- : options.markdown
+ ? "prettier"
+ : options.markdown;
const GLOB_SLIDEV = options.slidev
? options.slidev === true
- ? ['**/slides.md']
+ ? ["**/slides.md"]
: options.slidev.files
- : []
+ : [];
configs.push({
files: [GLOB_MARKDOWN],
@@ -195,24 +195,24 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/markdown',
+ name: "antfu/formatter/markdown",
rules: {
[`format/${formater}`]: [
- 'error',
- formater === 'prettier'
+ "error",
+ formater === "prettier"
? {
printWidth: 120,
...prettierOptions,
- embeddedLanguageFormatting: 'off',
- parser: 'markdown',
+ embeddedLanguageFormatting: "off",
+ parser: "markdown",
}
: {
...dprintOptions,
- language: 'markdown',
+ language: "markdown",
},
],
},
- })
+ });
if (options.slidev) {
configs.push({
@@ -220,22 +220,22 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/slidev',
+ name: "antfu/formatter/slidev",
rules: {
- 'format/prettier': [
- 'error',
+ "format/prettier": [
+ "error",
{
printWidth: 120,
...prettierOptions,
- embeddedLanguageFormatting: 'off',
- parser: 'slidev',
+ embeddedLanguageFormatting: "off",
+ parser: "slidev",
plugins: [
- 'prettier-plugin-slidev',
+ "prettier-plugin-slidev",
],
},
],
},
- })
+ });
}
}
@@ -245,20 +245,20 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/astro',
+ name: "antfu/formatter/astro",
rules: {
- 'format/prettier': [
- 'error',
+ "format/prettier": [
+ "error",
{
...prettierOptions,
- parser: 'astro',
+ parser: "astro",
plugins: [
- 'prettier-plugin-astro',
+ "prettier-plugin-astro",
],
},
],
},
- })
+ });
}
if (options.graphql) {
@@ -267,18 +267,18 @@ export async function formatters(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/formatter/graphql',
+ name: "antfu/formatter/graphql",
rules: {
- 'format/prettier': [
- 'error',
+ "format/prettier": [
+ "error",
{
...prettierOptions,
- parser: 'graphql',
+ parser: "graphql",
},
],
},
- })
+ });
}
- return configs
+ return configs;
}
diff --git a/src/configs/i18n.ts b/src/configs/i18n.ts
index fcf93c83cc..7fd8d316b5 100644
--- a/src/configs/i18n.ts
+++ b/src/configs/i18n.ts
@@ -1,66 +1,66 @@
-import path from 'node:path'
-import { fixupConfigRules } from '@eslint/compat'
-import { ensurePackages } from '../utils'
-import type { TypedFlatConfigItem } from '../types'
-import { compat } from '../compat'
+import path from "node:path";
+import { fixupConfigRules } from "@eslint/compat";
+import { ensurePackages } from "../utils";
+import type { TypedFlatConfigItem } from "../types";
+import { compat } from "../compat";
export async function i18n(): Promise> {
await ensurePackages([
- 'eslint-plugin-i18n-checker',
- 'eslint-plugin-i18n-json',
- 'eslint-plugin-i18n-prefix',
- 'eslint-plugin-i18next',
- '@naturacosmeticos/i18n-checker',
- ])
+ "eslint-plugin-i18n-checker",
+ "eslint-plugin-i18n-json",
+ "eslint-plugin-i18n-prefix",
+ "eslint-plugin-i18next",
+ "@naturacosmeticos/i18n-checker",
+ ]);
return [
{
- name: 'nirtami2/i18n',
+ name: "nirtami2/i18n",
...fixupConfigRules(
compat.config({
extends: [
- 'plugin:i18n-prefix/recommended',
- 'plugin:i18next/recommended',
+ "plugin:i18n-prefix/recommended",
+ "plugin:i18next/recommended",
],
- plugins: ['@naturacosmeticos/i18n-checker'],
+ plugins: ["@naturacosmeticos/i18n-checker"],
rules: {
/**
* This will error if `t` function called with a translation key
* that does not exist in translation files
*/
- '@naturacosmeticos/i18n-checker/path-in-locales': [
- 'error',
+ "@naturacosmeticos/i18n-checker/path-in-locales": [
+ "error",
{
- localesPath: 'locales/',
- messagesBasePath: 'translations',
- translationFunctionName: 't',
+ localesPath: "locales/",
+ messagesBasePath: "translations",
+ translationFunctionName: "t",
},
],
/**
* i18n translation should be the same as component name
*/
- 'i18n-prefix/i18n-prefix': [
- 'error',
+ "i18n-prefix/i18n-prefix": [
+ "error",
{
- translationFunctionName: 't',
- delimiter: '.',
- ignorePrefixes: ['enum'],
+ translationFunctionName: "t",
+ delimiter: ".",
+ ignorePrefixes: ["enum"],
},
],
},
overrides: [
{
- files: ['**/locales/**/*.json'],
- extends: ['plugin:i18n-json/recommended'],
+ files: ["**/locales/**/*.json"],
+ extends: ["plugin:i18n-json/recommended"],
rules: {
- 'i18n-json/valid-message-syntax': [
- 'error',
+ "i18n-json/valid-message-syntax": [
+ "error",
{
/**
* This allows using the i18next format with {param} syntax
* @see https://github.com/godaddy/eslint-plugin-i18n-json/issues/40#issuecomment-842474651
*/
- syntax: path.resolve('./i18next-syntax-validator.mjs'),
+ syntax: path.resolve("./i18next-syntax-validator.mjs"),
},
],
},
@@ -69,5 +69,5 @@ export async function i18n(): Promise> {
}),
),
},
- ]
+ ];
}
diff --git a/src/configs/i18next-syntax-validator.mjs b/src/configs/i18next-syntax-validator.mjs
index 6b9dd58b99..7516af2f9f 100644
--- a/src/configs/i18next-syntax-validator.mjs
+++ b/src/configs/i18next-syntax-validator.mjs
@@ -2,24 +2,24 @@
* @param {string} message i18n message
* @see https://github.com/godaddy/eslint-plugin-i18n-json/issues/40#issuecomment-842474651
*/
-export default function validate(message = '') {
- if (!(message || '').trim()) {
- throw new SyntaxError('Message is Empty.')
+export default function validate(message = "") {
+ if (!(message || "").trim()) {
+ throw new SyntaxError("Message is Empty.");
}
- if (typeof message !== 'string') {
- throw new TypeError('Message must be a String.')
+ if (typeof message !== "string") {
+ throw new TypeError("Message must be a String.");
}
if (
- (message.includes('{') || message.includes('}'))
+ (message.includes("{") || message.includes("}"))
&& !/{{ ?(?:- |\w+)(?:, ?\w+)? ?}}/.test(message)
) {
throw new SyntaxError(
- 'Interpolation error. See: https://www.i18next.com/misc/json-format',
- )
+ "Interpolation error. See: https://www.i18next.com/misc/json-format",
+ );
}
- if (message.includes('$t(') && !/\$t\(\w+:\w+(?:\.\w+)*\)/.test(message)) {
+ if (message.includes("$t(") && !/\$t\(\w+:\w+(?:\.\w+)*\)/.test(message)) {
throw new SyntaxError(
- 'Nesting error. See: https://www.i18next.com/misc/json-format',
- )
+ "Nesting error. See: https://www.i18next.com/misc/json-format",
+ );
}
}
diff --git a/src/configs/ignores.ts b/src/configs/ignores.ts
index 966928d979..c7646080d2 100644
--- a/src/configs/ignores.ts
+++ b/src/configs/ignores.ts
@@ -1,5 +1,5 @@
-import type { TypedFlatConfigItem } from '../types'
-import { GLOB_EXCLUDE } from '../globs'
+import type { TypedFlatConfigItem } from "../types";
+import { GLOB_EXCLUDE } from "../globs";
export async function ignores(): Promise> {
return [
@@ -8,5 +8,5 @@ export async function ignores(): Promise> {
// Awaits https://github.com/humanwhocodes/config-array/pull/131
// name: 'antfu/ignores',
},
- ]
+ ];
}
diff --git a/src/configs/imports.ts b/src/configs/imports.ts
index a9fc5cf311..4b0cbf8755 100644
--- a/src/configs/imports.ts
+++ b/src/configs/imports.ts
@@ -1,46 +1,46 @@
-import type { OptionsStylistic, TypedFlatConfigItem } from '../types'
-import { pluginAntfu, pluginImport } from '../plugins'
-import { GLOB_SRC_EXT } from '../globs'
+import type { OptionsStylistic, TypedFlatConfigItem } from "../types";
+import { pluginAntfu, pluginImport } from "../plugins";
+import { GLOB_SRC_EXT } from "../globs";
export async function imports(options: OptionsStylistic = {}): Promise> {
const {
stylistic = true,
- } = options
+ } = options;
return [
{
- name: 'antfu/imports/rules',
+ name: "antfu/imports/rules",
plugins: {
- 'antfu': pluginAntfu,
- 'import-x': pluginImport,
+ "antfu": pluginAntfu,
+ "import-x": pluginImport,
},
rules: {
- 'antfu/import-dedupe': 'error',
- 'antfu/no-import-dist': 'error',
- 'antfu/no-import-node-modules-by-path': 'error',
+ "antfu/import-dedupe": "error",
+ "antfu/no-import-dist": "error",
+ "antfu/no-import-node-modules-by-path": "error",
- 'import-x/first': 'error',
- 'import-x/no-duplicates': 'error',
- 'import-x/no-mutable-exports': 'error',
- 'import-x/no-named-default': 'error',
- 'import-x/no-self-import': 'error',
- 'import-x/no-webpack-loader-syntax': 'error',
- 'import-x/order': 'off', // use prettier for it
+ "import-x/first": "error",
+ "import-x/no-duplicates": "error",
+ "import-x/no-mutable-exports": "error",
+ "import-x/no-named-default": "error",
+ "import-x/no-self-import": "error",
+ "import-x/no-webpack-loader-syntax": "error",
+ "import-x/order": "off", // use prettier for it
...stylistic
? {
- 'import-x/newline-after-import': ['error', { count: 1 }],
+ "import-x/newline-after-import": ["error", { count: 1 }],
}
: {},
},
},
{
- files: ['**/bin/**/*', `**/bin.${GLOB_SRC_EXT}`],
- name: 'antfu/imports/disables/bin',
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
+ name: "antfu/imports/disables/bin",
rules: {
- 'antfu/no-import-dist': 'off',
- 'antfu/no-import-node-modules-by-path': 'off',
+ "antfu/no-import-dist": "off",
+ "antfu/no-import-node-modules-by-path": "off",
},
},
- ]
+ ];
}
diff --git a/src/configs/index.ts b/src/configs/index.ts
index 7c449849ac..f8b8776866 100644
--- a/src/configs/index.ts
+++ b/src/configs/index.ts
@@ -1,25 +1,25 @@
-export * from './astro'
-export * from './command'
-export * from './comments'
-export * from './formatters'
-export * from './ignores'
-export * from './imports'
-export * from './javascript'
-export * from './jsdoc'
-export * from './jsonc'
-export * from './markdown'
-export * from './node'
-export * from './perfectionist'
-export * from './react'
-export * from './solid'
-export * from './sort'
-export * from './stylistic'
-export * from './svelte'
-export * from './test'
-export * from './toml'
-export * from './typescript'
-export * from './unicorn'
-export * from './unocss'
-export * from './vue'
-export * from './yaml'
-export * from './regexp'
+export * from "./astro";
+export * from "./command";
+export * from "./comments";
+export * from "./formatters";
+export * from "./ignores";
+export * from "./imports";
+export * from "./javascript";
+export * from "./jsdoc";
+export * from "./jsonc";
+export * from "./markdown";
+export * from "./node";
+export * from "./perfectionist";
+export * from "./react";
+export * from "./solid";
+export * from "./sort";
+export * from "./stylistic";
+export * from "./svelte";
+export * from "./test";
+export * from "./toml";
+export * from "./typescript";
+export * from "./unicorn";
+export * from "./unocss";
+export * from "./vue";
+export * from "./yaml";
+export * from "./regexp";
diff --git a/src/configs/javascript.ts b/src/configs/javascript.ts
index 01afe764fb..07f8eeed0c 100644
--- a/src/configs/javascript.ts
+++ b/src/configs/javascript.ts
@@ -1,5 +1,5 @@
-import globals from 'globals'
-import type { OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types'
+import globals from "globals";
+import type { OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from "../types";
import {
arrayFunc,
confusingBrowserGlobals,
@@ -7,11 +7,11 @@ import {
js,
pluginAntfu,
pluginUnusedImports,
-} from '../plugins'
-import { GLOB_SRC, GLOB_SRC_EXT } from '../globs'
-import { fixupConfigRules } from '@eslint/compat'
-import sonarjs from 'eslint-plugin-sonarjs'
-import { compat } from '../compat'
+} from "../plugins";
+import { GLOB_SRC, GLOB_SRC_EXT } from "../globs";
+import { fixupConfigRules } from "@eslint/compat";
+import sonarjs from "eslint-plugin-sonarjs";
+import { compat } from "../compat";
export async function javascript(
options: OptionsIsInEditor & OptionsOverrides = {},
@@ -19,115 +19,115 @@ export async function javascript(
const {
isInEditor = false,
overrides = {},
- } = options
+ } = options;
return [
js.configs.recommended,
{
- name: 'nirtamir2/javascript/overrides',
+ name: "nirtamir2/javascript/overrides",
rules: {
// #region eslint
- 'no-constant-binary-expression': 'error',
- 'max-params': 'error',
+ "no-constant-binary-expression": "error",
+ "max-params": "error",
// ignore eslint prettier that remove this rule, because I want to remove useless template literal
// quotes: [2, "double", { allowTemplateLiterals: false }],
- 'no-implicit-coercion': ['error'],
- 'prefer-destructuring': ['error', { object: true, array: false }], // a[0] should not destruct
- 'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
+ "no-implicit-coercion": ["error"],
+ "prefer-destructuring": ["error", { object: true, array: false }], // a[0] should not destruct
+ "func-style": ["error", "declaration", { allowArrowFunctions: true }],
// Based on https://github.com/antfu/eslint-config/blob/master/packages/basic/index.js
// Common
- 'no-param-reassign': 'off',
- 'camelcase': 'off',
- 'no-constant-condition': 'warn',
- 'no-debugger': 'error',
- 'no-console': ['error', { allow: ['warn', 'error'] }],
- 'no-cond-assign': ['error', 'always'],
- 'no-restricted-globals': ['error', ...confusingBrowserGlobals],
- 'no-restricted-syntax': [
- 'error',
- 'DebuggerStatement',
- 'ForInStatement',
- 'LabeledStatement',
- 'WithStatement',
+ "no-param-reassign": "off",
+ "camelcase": "off",
+ "no-constant-condition": "warn",
+ "no-debugger": "error",
+ "no-console": ["error", { allow: ["warn", "error"] }],
+ "no-cond-assign": ["error", "always"],
+ "no-restricted-globals": ["error", ...confusingBrowserGlobals],
+ "no-restricted-syntax": [
+ "error",
+ "DebuggerStatement",
+ "ForInStatement",
+ "LabeledStatement",
+ "WithStatement",
],
// es6
- 'no-var': 'error',
- 'prefer-const': [
- 'error',
+ "no-var": "error",
+ "prefer-const": [
+ "error",
{
- destructuring: 'any',
+ destructuring: "any",
ignoreReadBeforeAssign: true,
},
],
- 'prefer-arrow-callback': [
- 'error',
+ "prefer-arrow-callback": [
+ "error",
{
allowNamedFunctions: false,
allowUnboundThis: true,
},
],
- 'object-shorthand': [
- 'error',
- 'always',
+ "object-shorthand": [
+ "error",
+ "always",
{
ignoreConstructors: false,
avoidQuotes: true,
},
],
- 'prefer-rest-params': 'error',
- 'prefer-spread': 'error',
- 'prefer-template': 'error',
+ "prefer-rest-params": "error",
+ "prefer-spread": "error",
+ "prefer-template": "error",
// best-practice
- 'array-callback-return': 'error',
- 'block-scoped-var': 'error',
- 'consistent-return': 'off',
- 'complexity': ['off', 11],
- 'eqeqeq': ['error', 'always', { null: 'ignore' }],
- 'no-alert': 'warn',
- 'no-case-declarations': 'error',
- 'no-multi-str': 'error',
- 'no-with': 'error',
- 'no-useless-escape': 'off',
- 'vars-on-top': 'error',
- 'require-await': 'off',
- 'no-return-assign': 'off',
+ "array-callback-return": "error",
+ "block-scoped-var": "error",
+ "consistent-return": "off",
+ "complexity": ["off", 11],
+ "eqeqeq": ["error", "always", { null: "ignore" }],
+ "no-alert": "warn",
+ "no-case-declarations": "error",
+ "no-multi-str": "error",
+ "no-with": "error",
+ "no-useless-escape": "off",
+ "vars-on-top": "error",
+ "require-await": "off",
+ "no-return-assign": "off",
},
},
arrayFunc.configs.recommended,
{
- name: 'nirtamir2/javascript/arrayFunc/overrides',
+ name: "nirtamir2/javascript/arrayFunc/overrides",
rules: {
- 'array-func/prefer-array-from': 0, // conflicts with unicorn/prefer-spread
+ "array-func/prefer-array-from": 0, // conflicts with unicorn/prefer-spread
},
},
...fixupConfigRules(
compat.config({
- plugins: ['github'],
+ plugins: ["github"],
rules: {
- 'github/a11y-no-generic-link-text': 2,
- 'github/array-foreach': 2,
- 'github/async-currenttarget': 2,
- 'github/async-preventdefault': 2,
- 'github/authenticity-token': 2,
- 'github/get-attribute': 2,
- 'github/js-class-name': 2,
- 'github/no-blur': 2,
- 'github/no-d-none': 2,
- 'github/no-dataset': 2,
- 'github/no-implicit-buggy-globals': 2,
- 'github/no-inner-html': 2,
- 'github/no-innerText': 2,
- 'github/no-dynamic-script-tag': 2,
- 'github/no-then': 2,
- 'github/no-useless-passive': 2,
- 'github/prefer-observers': 2,
- 'github/require-passive-events': 2,
- 'github/unescaped-html-literal': 2,
+ "github/a11y-no-generic-link-text": 2,
+ "github/array-foreach": 2,
+ "github/async-currenttarget": 2,
+ "github/async-preventdefault": 2,
+ "github/authenticity-token": 2,
+ "github/get-attribute": 2,
+ "github/js-class-name": 2,
+ "github/no-blur": 2,
+ "github/no-d-none": 2,
+ "github/no-dataset": 2,
+ "github/no-implicit-buggy-globals": 2,
+ "github/no-inner-html": 2,
+ "github/no-innerText": 2,
+ "github/no-dynamic-script-tag": 2,
+ "github/no-then": 2,
+ "github/no-useless-passive": 2,
+ "github/prefer-observers": 2,
+ "github/require-passive-events": 2,
+ "github/unescaped-html-literal": 2,
},
}),
),
@@ -138,234 +138,234 @@ export async function javascript(
...globals.browser,
...globals.es2021,
...globals.node,
- document: 'readonly',
- navigator: 'readonly',
- window: 'readonly',
+ document: "readonly",
+ navigator: "readonly",
+ window: "readonly",
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2022,
- sourceType: 'module',
+ sourceType: "module",
},
- sourceType: 'module',
+ sourceType: "module",
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
- name: 'antfu/javascript/rules',
+ name: "antfu/javascript/rules",
plugins: {
- 'antfu': pluginAntfu,
- 'unused-imports': pluginUnusedImports,
+ "antfu": pluginAntfu,
+ "unused-imports": pluginUnusedImports,
},
rules: {
- 'accessor-pairs': ['error', { enforceForClassMembers: true, setWithoutGet: true }],
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
- 'array-callback-return': 'error',
- 'block-scoped-var': 'error',
- 'constructor-super': 'error',
- 'default-case-last': 'error',
- 'dot-notation': ['error', { allowKeywords: true }],
- 'eqeqeq': ['error', 'smart'],
- 'new-cap': ['error', { capIsNew: false, newIsCap: true, properties: true }],
- 'no-alert': 'error',
- 'no-array-constructor': 'error',
- 'no-async-promise-executor': 'error',
- 'no-caller': 'error',
- 'no-case-declarations': 'error',
- 'no-class-assign': 'error',
- 'no-compare-neg-zero': 'error',
- 'no-cond-assign': ['error', 'always'],
- 'no-console': ['error', { allow: ['warn', 'error'] }],
- 'no-const-assign': 'error',
- 'no-control-regex': 'error',
- 'no-debugger': 'error',
- 'no-delete-var': 'error',
- 'no-dupe-args': 'error',
- 'no-dupe-class-members': 'error',
- 'no-dupe-keys': 'error',
- 'no-duplicate-case': 'error',
- 'no-empty': ['error', { allowEmptyCatch: true }],
- 'no-empty-character-class': 'error',
- 'no-empty-pattern': 'error',
- 'no-eval': 'error',
- 'no-ex-assign': 'error',
- 'no-extend-native': 'error',
- 'no-extra-bind': 'error',
- 'no-extra-boolean-cast': 'error',
- 'no-fallthrough': 'error',
- 'no-func-assign': 'error',
- 'no-global-assign': 'error',
- 'no-implied-eval': 'error',
- 'no-import-assign': 'error',
- 'no-invalid-regexp': 'error',
- 'no-irregular-whitespace': 'error',
- 'no-iterator': 'error',
- 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
- 'no-lone-blocks': 'error',
- 'no-loss-of-precision': 'error',
- 'no-misleading-character-class': 'error',
- 'no-multi-str': 'error',
- 'no-new': 'error',
- 'no-new-func': 'error',
- 'no-new-native-nonconstructor': 'error',
- 'no-new-wrappers': 'error',
- 'no-obj-calls': 'error',
- 'no-octal': 'error',
- 'no-octal-escape': 'error',
- 'no-proto': 'error',
- 'no-prototype-builtins': 'error',
- 'no-redeclare': ['error', { builtinGlobals: false }],
- 'no-regex-spaces': 'error',
- 'no-restricted-globals': [
- 'error',
- { message: 'Use `globalThis` instead.', name: 'global' },
- { message: 'Use `globalThis` instead.', name: 'self' },
+ "array-callback-return": "error",
+ "block-scoped-var": "error",
+ "constructor-super": "error",
+ "default-case-last": "error",
+ "dot-notation": ["error", { allowKeywords: true }],
+ "eqeqeq": ["error", "smart"],
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
+ "no-alert": "error",
+ "no-array-constructor": "error",
+ "no-async-promise-executor": "error",
+ "no-caller": "error",
+ "no-case-declarations": "error",
+ "no-class-assign": "error",
+ "no-compare-neg-zero": "error",
+ "no-cond-assign": ["error", "always"],
+ "no-console": ["error", { allow: ["warn", "error"] }],
+ "no-const-assign": "error",
+ "no-control-regex": "error",
+ "no-debugger": "error",
+ "no-delete-var": "error",
+ "no-dupe-args": "error",
+ "no-dupe-class-members": "error",
+ "no-dupe-keys": "error",
+ "no-duplicate-case": "error",
+ "no-empty": ["error", { allowEmptyCatch: true }],
+ "no-empty-character-class": "error",
+ "no-empty-pattern": "error",
+ "no-eval": "error",
+ "no-ex-assign": "error",
+ "no-extend-native": "error",
+ "no-extra-bind": "error",
+ "no-extra-boolean-cast": "error",
+ "no-fallthrough": "error",
+ "no-func-assign": "error",
+ "no-global-assign": "error",
+ "no-implied-eval": "error",
+ "no-import-assign": "error",
+ "no-invalid-regexp": "error",
+ "no-irregular-whitespace": "error",
+ "no-iterator": "error",
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
+ "no-lone-blocks": "error",
+ "no-loss-of-precision": "error",
+ "no-misleading-character-class": "error",
+ "no-multi-str": "error",
+ "no-new": "error",
+ "no-new-func": "error",
+ "no-new-native-nonconstructor": "error",
+ "no-new-wrappers": "error",
+ "no-obj-calls": "error",
+ "no-octal": "error",
+ "no-octal-escape": "error",
+ "no-proto": "error",
+ "no-prototype-builtins": "error",
+ "no-redeclare": ["error", { builtinGlobals: false }],
+ "no-regex-spaces": "error",
+ "no-restricted-globals": [
+ "error",
+ { message: "Use `globalThis` instead.", name: "global" },
+ { message: "Use `globalThis` instead.", name: "self" },
],
- 'no-restricted-properties': [
- 'error',
- { message: 'Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.', property: '__proto__' },
- { message: 'Use `Object.defineProperty` instead.', property: '__defineGetter__' },
- { message: 'Use `Object.defineProperty` instead.', property: '__defineSetter__' },
- { message: 'Use `Object.getOwnPropertyDescriptor` instead.', property: '__lookupGetter__' },
- { message: 'Use `Object.getOwnPropertyDescriptor` instead.', property: '__lookupSetter__' },
+ "no-restricted-properties": [
+ "error",
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" },
],
- 'no-restricted-syntax': [
- 'error',
- 'DebuggerStatement',
- 'LabeledStatement',
- 'WithStatement',
- 'TSEnumDeclaration[const=true]',
- 'TSExportAssignment',
+ "no-restricted-syntax": [
+ "error",
+ "DebuggerStatement",
+ "LabeledStatement",
+ "WithStatement",
+ "TSEnumDeclaration[const=true]",
+ "TSExportAssignment",
],
- 'no-self-assign': ['error', { props: true }],
- 'no-self-compare': 'error',
- 'no-sequences': 'error',
- 'no-shadow-restricted-names': 'error',
- 'no-sparse-arrays': 'error',
- 'no-template-curly-in-string': 'error',
- 'no-this-before-super': 'error',
- 'no-throw-literal': 'error',
- 'no-undef': 'error',
- 'no-undef-init': 'error',
- 'no-unexpected-multiline': 'error',
- 'no-unmodified-loop-condition': 'error',
- 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
- 'no-unreachable': 'error',
- 'no-unreachable-loop': 'error',
- 'no-unsafe-finally': 'error',
- 'no-unsafe-negation': 'error',
- 'no-unused-expressions': ['error', {
+ "no-self-assign": ["error", { props: true }],
+ "no-self-compare": "error",
+ "no-sequences": "error",
+ "no-shadow-restricted-names": "error",
+ "no-sparse-arrays": "error",
+ "no-template-curly-in-string": "error",
+ "no-this-before-super": "error",
+ "no-throw-literal": "error",
+ "no-undef": "error",
+ "no-undef-init": "error",
+ "no-unexpected-multiline": "error",
+ "no-unmodified-loop-condition": "error",
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
+ "no-unreachable": "error",
+ "no-unreachable-loop": "error",
+ "no-unsafe-finally": "error",
+ "no-unsafe-negation": "error",
+ "no-unused-expressions": ["error", {
allowShortCircuit: true,
allowTaggedTemplates: true,
allowTernary: true,
}],
- 'no-unused-vars': ['error', {
- args: 'none',
- caughtErrors: 'none',
+ "no-unused-vars": ["error", {
+ args: "none",
+ caughtErrors: "none",
ignoreRestSiblings: true,
- vars: 'all',
+ vars: "all",
}],
- 'no-use-before-define': ['error', { classes: false, functions: false, variables: true }],
- 'no-useless-backreference': 'error',
- 'no-useless-call': 'error',
- 'no-useless-catch': 'error',
- 'no-useless-computed-key': 'error',
- 'no-useless-constructor': 'error',
- 'no-useless-rename': 'error',
- 'no-useless-return': 'error',
- 'no-var': 'error',
- 'no-with': 'error',
- 'object-shorthand': [
- 'error',
- 'always',
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
+ "no-useless-backreference": "error",
+ "no-useless-call": "error",
+ "no-useless-catch": "error",
+ "no-useless-computed-key": "error",
+ "no-useless-constructor": "error",
+ "no-useless-rename": "error",
+ "no-useless-return": "error",
+ "no-var": "error",
+ "no-with": "error",
+ "object-shorthand": [
+ "error",
+ "always",
{
avoidQuotes: true,
ignoreConstructors: false,
},
],
- 'one-var': ['error', { initialized: 'never' }],
- 'prefer-arrow-callback': [
- 'error',
+ "one-var": ["error", { initialized: "never" }],
+ "prefer-arrow-callback": [
+ "error",
{
allowNamedFunctions: false,
allowUnboundThis: true,
},
],
- 'prefer-const': [
- 'error',
+ "prefer-const": [
+ "error",
{
- destructuring: 'all',
+ destructuring: "all",
ignoreReadBeforeAssign: true,
},
],
- 'prefer-exponentiation-operator': 'error',
- 'prefer-promise-reject-errors': 'error',
- 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
- 'prefer-rest-params': 'error',
- 'prefer-spread': 'error',
- 'prefer-template': 'error',
- 'sort-imports': [
- 'error',
+ "prefer-exponentiation-operator": "error",
+ "prefer-promise-reject-errors": "error",
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
+ "prefer-rest-params": "error",
+ "prefer-spread": "error",
+ "prefer-template": "error",
+ "sort-imports": [
+ "error",
{
allowSeparatedGroups: false,
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
- memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
},
],
- 'symbol-description': 'error',
- 'unicode-bom': ['error', 'never'],
- 'unused-imports/no-unused-imports': isInEditor ? 'off' : 'error',
- 'unused-imports/no-unused-vars': [
- 'error',
+ "symbol-description": "error",
+ "unicode-bom": ["error", "never"],
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
+ "unused-imports/no-unused-vars": [
+ "error",
{
- args: 'after-used',
- argsIgnorePattern: '^_',
+ args: "after-used",
+ argsIgnorePattern: "^_",
ignoreRestSiblings: true,
- vars: 'all',
- varsIgnorePattern: '^_',
+ vars: "all",
+ varsIgnorePattern: "^_",
},
],
- 'use-isnan': ['error', { enforceForIndexOf: true, enforceForSwitchCase: true }],
- 'valid-typeof': ['error', { requireStringLiterals: true }],
- 'vars-on-top': 'error',
- 'yoda': ['error', 'never'],
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
+ "valid-typeof": ["error", { requireStringLiterals: true }],
+ "vars-on-top": "error",
+ "yoda": ["error", "never"],
...overrides,
},
},
{
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
- name: 'antfu/javascript/disables/cli',
+ name: "antfu/javascript/disables/cli",
rules: {
- 'no-console': 'off',
+ "no-console": "off",
},
},
{
- name: 'nirtamir2/javascript/overrides',
+ name: "nirtamir2/javascript/overrides",
rules: {
- 'dot-notation': 'off', // Collide with TypeScript TS4111: Property comes from an index signature, so it must be accessed with [].
+ "dot-notation": "off", // Collide with TypeScript TS4111: Property comes from an index signature, so it must be accessed with [].
},
},
...fixupConfigRules(
compat.config({
- extends: ['plugin:optimize-regex/recommended'],
+ extends: ["plugin:optimize-regex/recommended"],
}),
),
...fixupConfigRules(
compat.config({
- extends: ['plugin:workspaces/recommended'],
+ extends: ["plugin:workspaces/recommended"],
}),
),
...compat.config({
- extends: ['plugin:eslint-comments/recommended'],
+ extends: ["plugin:eslint-comments/recommended"],
}),
eslintPluginNoUseExtendNative.configs.recommended,
sonarjs.configs.recommended,
- ...compat.extends('plugin:clsx/recommended'),
- ]
+ ...compat.extends("plugin:clsx/recommended"),
+ ];
}
diff --git a/src/configs/jsdoc.ts b/src/configs/jsdoc.ts
index d751160210..9f5675949e 100644
--- a/src/configs/jsdoc.ts
+++ b/src/configs/jsdoc.ts
@@ -1,49 +1,49 @@
-import { interopDefault } from '../utils'
-import type { OptionsStylistic, TypedFlatConfigItem } from '../types'
-import jsdocPlugin from 'eslint-plugin-jsdoc'
+import { interopDefault } from "../utils";
+import type { OptionsStylistic, TypedFlatConfigItem } from "../types";
+import jsdocPlugin from "eslint-plugin-jsdoc";
export async function jsdoc(options: OptionsStylistic = {}): Promise> {
const {
stylistic = true,
- } = options
+ } = options;
return [
{
- name: 'antfu/jsdoc/rules',
+ name: "antfu/jsdoc/rules",
plugins: {
- jsdoc: await interopDefault(import('eslint-plugin-jsdoc')),
+ jsdoc: await interopDefault(import("eslint-plugin-jsdoc")),
},
rules: {
- 'jsdoc/check-access': 'warn',
- 'jsdoc/check-param-names': 'warn',
- 'jsdoc/check-property-names': 'warn',
- 'jsdoc/check-types': 'warn',
- 'jsdoc/empty-tags': 'warn',
- 'jsdoc/implements-on-classes': 'warn',
- 'jsdoc/no-defaults': 'warn',
- 'jsdoc/no-multi-asterisks': 'warn',
- 'jsdoc/require-param-name': 'warn',
- 'jsdoc/require-property': 'warn',
- 'jsdoc/require-property-description': 'warn',
- 'jsdoc/require-property-name': 'warn',
- 'jsdoc/require-returns-check': 'warn',
- 'jsdoc/require-returns-description': 'warn',
- 'jsdoc/require-yields-check': 'warn',
+ "jsdoc/check-access": "warn",
+ "jsdoc/check-param-names": "warn",
+ "jsdoc/check-property-names": "warn",
+ "jsdoc/check-types": "warn",
+ "jsdoc/empty-tags": "warn",
+ "jsdoc/implements-on-classes": "warn",
+ "jsdoc/no-defaults": "warn",
+ "jsdoc/no-multi-asterisks": "warn",
+ "jsdoc/require-param-name": "warn",
+ "jsdoc/require-property": "warn",
+ "jsdoc/require-property-description": "warn",
+ "jsdoc/require-property-name": "warn",
+ "jsdoc/require-returns-check": "warn",
+ "jsdoc/require-returns-description": "warn",
+ "jsdoc/require-yields-check": "warn",
...stylistic
? {
- 'jsdoc/check-alignment': 'warn',
- 'jsdoc/multiline-blocks': 'warn',
+ "jsdoc/check-alignment": "warn",
+ "jsdoc/multiline-blocks": "warn",
}
: {},
},
},
- jsdocPlugin.configs['flat/recommended-typescript-flavor'],
+ jsdocPlugin.configs["flat/recommended-typescript-flavor"],
{
- name: 'nirtami2/jsdoc/overrides',
+ name: "nirtami2/jsdoc/overrides",
rules: {
- 'jsdoc/require-jsdoc': 'off',
+ "jsdoc/require-jsdoc": "off",
},
},
- ]
+ ];
}
diff --git a/src/configs/jsonc.ts b/src/configs/jsonc.ts
index 44b22827d5..dd883b1976 100644
--- a/src/configs/jsonc.ts
+++ b/src/configs/jsonc.ts
@@ -1,6 +1,6 @@
-import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types'
-import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from '../globs'
-import { interopDefault } from '../utils'
+import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from "../types";
+import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from "../globs";
+import { interopDefault } from "../utils";
export async function jsonc(
options: OptionsFiles & OptionsStylistic & OptionsOverrides = {},
@@ -9,23 +9,23 @@ export async function jsonc(
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
overrides = {},
stylistic = true,
- } = options
+ } = options;
const {
indent = 2,
- } = typeof stylistic === 'boolean' ? {} : stylistic
+ } = typeof stylistic === "boolean" ? {} : stylistic;
const [
pluginJsonc,
parserJsonc,
] = await Promise.all([
- interopDefault(import('eslint-plugin-jsonc')),
- interopDefault(import('jsonc-eslint-parser')),
- ] as const)
+ interopDefault(import("eslint-plugin-jsonc")),
+ interopDefault(import("jsonc-eslint-parser")),
+ ] as const);
return [
{
- name: 'antfu/jsonc/setup',
+ name: "antfu/jsonc/setup",
plugins: {
jsonc: pluginJsonc as any,
},
@@ -35,52 +35,52 @@ export async function jsonc(
languageOptions: {
parser: parserJsonc,
},
- name: 'antfu/jsonc/rules',
+ name: "antfu/jsonc/rules",
rules: {
- 'jsonc/no-bigint-literals': 'error',
- 'jsonc/no-binary-expression': 'error',
- 'jsonc/no-binary-numeric-literals': 'error',
- 'jsonc/no-dupe-keys': 'error',
- 'jsonc/no-escape-sequence-in-identifier': 'error',
- 'jsonc/no-floating-decimal': 'error',
- 'jsonc/no-hexadecimal-numeric-literals': 'error',
- 'jsonc/no-infinity': 'error',
- 'jsonc/no-multi-str': 'error',
- 'jsonc/no-nan': 'error',
- 'jsonc/no-number-props': 'error',
- 'jsonc/no-numeric-separators': 'error',
- 'jsonc/no-octal': 'error',
- 'jsonc/no-octal-escape': 'error',
- 'jsonc/no-octal-numeric-literals': 'error',
- 'jsonc/no-parenthesized': 'error',
- 'jsonc/no-plus-sign': 'error',
- 'jsonc/no-regexp-literals': 'error',
- 'jsonc/no-sparse-arrays': 'error',
- 'jsonc/no-template-literals': 'error',
- 'jsonc/no-undefined-value': 'error',
- 'jsonc/no-unicode-codepoint-escapes': 'error',
- 'jsonc/no-useless-escape': 'error',
- 'jsonc/space-unary-ops': 'error',
- 'jsonc/valid-json-number': 'error',
- 'jsonc/vue-custom-block/no-parsing-error': 'error',
+ "jsonc/no-bigint-literals": "error",
+ "jsonc/no-binary-expression": "error",
+ "jsonc/no-binary-numeric-literals": "error",
+ "jsonc/no-dupe-keys": "error",
+ "jsonc/no-escape-sequence-in-identifier": "error",
+ "jsonc/no-floating-decimal": "error",
+ "jsonc/no-hexadecimal-numeric-literals": "error",
+ "jsonc/no-infinity": "error",
+ "jsonc/no-multi-str": "error",
+ "jsonc/no-nan": "error",
+ "jsonc/no-number-props": "error",
+ "jsonc/no-numeric-separators": "error",
+ "jsonc/no-octal": "error",
+ "jsonc/no-octal-escape": "error",
+ "jsonc/no-octal-numeric-literals": "error",
+ "jsonc/no-parenthesized": "error",
+ "jsonc/no-plus-sign": "error",
+ "jsonc/no-regexp-literals": "error",
+ "jsonc/no-sparse-arrays": "error",
+ "jsonc/no-template-literals": "error",
+ "jsonc/no-undefined-value": "error",
+ "jsonc/no-unicode-codepoint-escapes": "error",
+ "jsonc/no-useless-escape": "error",
+ "jsonc/space-unary-ops": "error",
+ "jsonc/valid-json-number": "error",
+ "jsonc/vue-custom-block/no-parsing-error": "error",
...stylistic
? {
- 'jsonc/array-bracket-spacing': ['error', 'never'],
- 'jsonc/comma-dangle': ['error', 'never'],
- 'jsonc/comma-style': ['error', 'last'],
- 'jsonc/indent': ['error', indent],
- 'jsonc/key-spacing': ['error', { afterColon: true, beforeColon: false }],
- 'jsonc/object-curly-newline': ['error', { consistent: true, multiline: true }],
- 'jsonc/object-curly-spacing': ['error', 'always'],
- 'jsonc/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
- 'jsonc/quote-props': 'error',
- 'jsonc/quotes': 'error',
+ "jsonc/array-bracket-spacing": ["error", "never"],
+ "jsonc/comma-dangle": ["error", "never"],
+ "jsonc/comma-style": ["error", "last"],
+ "jsonc/indent": ["error", indent],
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
+ "jsonc/object-curly-spacing": ["error", "always"],
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
+ "jsonc/quote-props": "error",
+ "jsonc/quotes": "error",
}
: {},
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/markdown.ts b/src/configs/markdown.ts
index 54b6913e88..0562972427 100644
--- a/src/configs/markdown.ts
+++ b/src/configs/markdown.ts
@@ -1,7 +1,7 @@
-import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors'
-import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, TypedFlatConfigItem } from '../types'
-import { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN } from '../globs'
-import { interopDefault, parserPlain } from '../utils'
+import { mergeProcessors, processorPassThrough } from "eslint-merge-processors";
+import type { OptionsComponentExts, OptionsFiles, OptionsOverrides, TypedFlatConfigItem } from "../types";
+import { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN } from "../globs";
+import { interopDefault, parserPlain } from "../utils";
export async function markdown(
options: OptionsFiles & OptionsComponentExts & OptionsOverrides = {},
@@ -10,14 +10,14 @@ export async function markdown(
componentExts = [],
files = [GLOB_MARKDOWN],
overrides = {},
- } = options
+ } = options;
// @ts-expect-error missing types
- const markdown = await interopDefault(import('eslint-plugin-markdown'))
+ const markdown = await interopDefault(import("eslint-plugin-markdown"));
return [
{
- name: 'antfu/markdown/setup',
+ name: "antfu/markdown/setup",
plugins: {
markdown,
},
@@ -25,7 +25,7 @@ export async function markdown(
{
files,
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
- name: 'antfu/markdown/processor',
+ name: "antfu/markdown/processor",
// `eslint-plugin-markdown` only creates virtual files for code blocks,
// but not the markdown file itself. We use `eslint-merge-processors` to
// add a pass-through processor for the markdown file itself.
@@ -39,7 +39,7 @@ export async function markdown(
languageOptions: {
parser: parserPlain,
},
- name: 'antfu/markdown/parser',
+ name: "antfu/markdown/parser",
},
{
files: [
@@ -53,57 +53,57 @@ export async function markdown(
},
},
},
- name: 'antfu/markdown/disables',
+ name: "antfu/markdown/disables",
rules: {
- 'import-x/newline-after-import': 'off',
+ "import-x/newline-after-import": "off",
- 'no-alert': 'off',
- 'no-console': 'off',
- 'no-labels': 'off',
- 'no-lone-blocks': 'off',
- 'no-restricted-syntax': 'off',
- 'no-undef': 'off',
- 'no-unused-expressions': 'off',
- 'no-unused-labels': 'off',
- 'no-unused-vars': 'off',
+ "no-alert": "off",
+ "no-console": "off",
+ "no-labels": "off",
+ "no-lone-blocks": "off",
+ "no-restricted-syntax": "off",
+ "no-undef": "off",
+ "no-unused-expressions": "off",
+ "no-unused-labels": "off",
+ "no-unused-vars": "off",
- 'n/prefer-global/process': 'off',
- '@stylistic/comma-dangle': 'off',
+ "n/prefer-global/process": "off",
+ "@stylistic/comma-dangle": "off",
- '@stylistic/eol-last': 'off',
- '@typescript-eslint/await-thenable': 'off',
- '@typescript-eslint/consistent-type-imports': 'off',
- '@typescript-eslint/dot-notation': 'off',
- '@typescript-eslint/no-floating-promises': 'off',
- '@typescript-eslint/no-for-in-array': 'off',
- '@typescript-eslint/no-implied-eval': 'off',
- '@typescript-eslint/no-misused-promises': 'off',
+ "@stylistic/eol-last": "off",
+ "@typescript-eslint/await-thenable": "off",
+ "@typescript-eslint/consistent-type-imports": "off",
+ "@typescript-eslint/dot-notation": "off",
+ "@typescript-eslint/no-floating-promises": "off",
+ "@typescript-eslint/no-for-in-array": "off",
+ "@typescript-eslint/no-implied-eval": "off",
+ "@typescript-eslint/no-misused-promises": "off",
- '@typescript-eslint/no-namespace': 'off',
- '@typescript-eslint/no-redeclare': 'off',
- '@typescript-eslint/no-require-imports': 'off',
+ "@typescript-eslint/no-namespace": "off",
+ "@typescript-eslint/no-redeclare": "off",
+ "@typescript-eslint/no-require-imports": "off",
// Type aware rules
- '@typescript-eslint/no-throw-literal': 'off',
- '@typescript-eslint/no-unnecessary-type-assertion': 'off',
- '@typescript-eslint/no-unsafe-argument': 'off',
- '@typescript-eslint/no-unsafe-assignment': 'off',
- '@typescript-eslint/no-unsafe-call': 'off',
- '@typescript-eslint/no-unsafe-member-access': 'off',
- '@typescript-eslint/no-unsafe-return': 'off',
- '@typescript-eslint/no-unused-vars': 'off',
- '@typescript-eslint/no-use-before-define': 'off',
- '@typescript-eslint/no-var-requires': 'off',
- '@typescript-eslint/restrict-plus-operands': 'off',
- '@typescript-eslint/restrict-template-expressions': 'off',
- '@typescript-eslint/unbound-method': 'off',
- 'unicode-bom': 'off',
- 'unused-imports/no-unused-imports': 'off',
- 'unused-imports/no-unused-vars': 'off',
+ "@typescript-eslint/no-throw-literal": "off",
+ "@typescript-eslint/no-unnecessary-type-assertion": "off",
+ "@typescript-eslint/no-unsafe-argument": "off",
+ "@typescript-eslint/no-unsafe-assignment": "off",
+ "@typescript-eslint/no-unsafe-call": "off",
+ "@typescript-eslint/no-unsafe-member-access": "off",
+ "@typescript-eslint/no-unsafe-return": "off",
+ "@typescript-eslint/no-unused-vars": "off",
+ "@typescript-eslint/no-use-before-define": "off",
+ "@typescript-eslint/no-var-requires": "off",
+ "@typescript-eslint/restrict-plus-operands": "off",
+ "@typescript-eslint/restrict-template-expressions": "off",
+ "@typescript-eslint/unbound-method": "off",
+ "unicode-bom": "off",
+ "unused-imports/no-unused-imports": "off",
+ "unused-imports/no-unused-vars": "off",
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/node.ts b/src/configs/node.ts
index 397a05bf4b..dd5d52c33a 100644
--- a/src/configs/node.ts
+++ b/src/configs/node.ts
@@ -1,23 +1,23 @@
-import type { TypedFlatConfigItem } from '../types'
-import { pluginNode } from '../plugins'
+import type { TypedFlatConfigItem } from "../types";
+import { pluginNode } from "../plugins";
export async function node(): Promise> {
return [
{
- name: 'antfu/node/rules',
+ name: "antfu/node/rules",
plugins: {
n: pluginNode,
},
rules: {
- 'n/handle-callback-err': ['error', '^(err|error)$'],
- 'n/no-deprecated-api': 'error',
- 'n/no-exports-assign': 'error',
- 'n/no-new-require': 'error',
- 'n/no-path-concat': 'error',
- 'n/prefer-global/buffer': ['error', 'never'],
- 'n/prefer-global/process': ['error', 'never'],
- 'n/process-exit-as-throw': 'error',
+ "n/handle-callback-err": ["error", "^(err|error)$"],
+ "n/no-deprecated-api": "error",
+ "n/no-exports-assign": "error",
+ "n/no-new-require": "error",
+ "n/no-path-concat": "error",
+ "n/prefer-global/buffer": ["error", "never"],
+ "n/prefer-global/process": ["error", "never"],
+ "n/process-exit-as-throw": "error",
},
},
- ]
+ ];
}
diff --git a/src/configs/perfectionist.ts b/src/configs/perfectionist.ts
index cfff5ca9d1..124fcba21b 100644
--- a/src/configs/perfectionist.ts
+++ b/src/configs/perfectionist.ts
@@ -1,5 +1,5 @@
-import type { TypedFlatConfigItem } from '../types'
-import { pluginPerfectionist } from '../plugins'
+import type { TypedFlatConfigItem } from "../types";
+import { pluginPerfectionist } from "../plugins";
/**
* Optional perfectionist plugin for props and items sorting.
@@ -8,10 +8,10 @@ import { pluginPerfectionist } from '../plugins'
export async function perfectionist(): Promise> {
return [
{
- name: 'antfu/perfectionist/setup',
+ name: "antfu/perfectionist/setup",
plugins: {
perfectionist: pluginPerfectionist,
},
},
- ]
+ ];
}
diff --git a/src/configs/prettier.ts b/src/configs/prettier.ts
index 2bdb078723..3f7ebf3117 100644
--- a/src/configs/prettier.ts
+++ b/src/configs/prettier.ts
@@ -1,10 +1,10 @@
-import type { TypedFlatConfigItem } from '../types'
-import { eslintConfigPrettier } from '../plugins'
+import type { TypedFlatConfigItem } from "../types";
+import { eslintConfigPrettier } from "../plugins";
/**
* Optional perfectionist plugin for props and items sorting.
* @see https://github.com/prettier/eslint-config-prettier
*/
export async function prettier(): Promise> {
- return eslintConfigPrettier
+ return eslintConfigPrettier;
}
diff --git a/src/configs/react.ts b/src/configs/react.ts
index bfd24dde54..01feef3a2e 100644
--- a/src/configs/react.ts
+++ b/src/configs/react.ts
@@ -1,24 +1,24 @@
-import { isPackageExists } from 'local-pkg'
-import { ensurePackages, interopDefault, toArray } from '../utils'
-import type { OptionsFiles, OptionsOverrides, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from '../types'
-import { GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX } from '../globs'
-import { fixupConfigRules } from '@eslint/compat'
-import { a11y } from './a11y'
-import { compat } from '../compat'
+import { isPackageExists } from "local-pkg";
+import { ensurePackages, interopDefault, toArray } from "../utils";
+import type { OptionsFiles, OptionsOverrides, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from "../types";
+import { GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX } from "../globs";
+import { fixupConfigRules } from "@eslint/compat";
+import { a11y } from "./a11y";
+import { compat } from "../compat";
// react refresh
const ReactRefreshAllowConstantExportPackages = [
- 'vite',
-]
+ "vite",
+];
const RemixPackages = [
- '@remix-run/node',
- '@remix-run/react',
- '@remix-run/serve',
- '@remix-run/dev',
-]
+ "@remix-run/node",
+ "@remix-run/react",
+ "@remix-run/serve",
+ "@remix-run/dev",
+];
const NextJsPackages = [
- 'next',
-]
+ "next",
+];
export async function react(
options: OptionsTypeScriptWithTypes & OptionsOverrides & OptionsFiles = {},
@@ -26,27 +26,27 @@ export async function react(
const {
files = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
overrides = {},
- } = options
+ } = options;
await ensurePackages([
- '@eslint-react/eslint-plugin',
- 'eslint-plugin-react-hooks',
- 'eslint-plugin-react-refresh',
- 'eslint-plugin-react',
- ])
+ "@eslint-react/eslint-plugin",
+ "eslint-plugin-react-hooks",
+ "eslint-plugin-react-refresh",
+ "eslint-plugin-react",
+ ]);
- const isUsingNext = NextJsPackages.some(i => isPackageExists(i))
+ const isUsingNext = NextJsPackages.some(i => isPackageExists(i));
if (isUsingNext) {
await ensurePackages(
- ['@next/eslint-plugin-next'],
- )
+ ["@next/eslint-plugin-next"],
+ );
}
const tsconfigPath = options?.tsconfigPath
? toArray(options.tsconfigPath)
- : undefined
- const isTypeAware = Boolean(tsconfigPath)
+ : undefined;
+ const isTypeAware = Boolean(tsconfigPath);
const [
pluginReact,
@@ -54,27 +54,27 @@ export async function react(
pluginReactRefresh,
parserTs,
] = await Promise.all([
- interopDefault(import('@eslint-react/eslint-plugin')),
- interopDefault(import('eslint-plugin-react-hooks')),
- interopDefault(import('eslint-plugin-react-refresh')),
- interopDefault(import('@typescript-eslint/parser')),
- ] as const)
+ interopDefault(import("@eslint-react/eslint-plugin")),
+ interopDefault(import("eslint-plugin-react-hooks")),
+ interopDefault(import("eslint-plugin-react-refresh")),
+ interopDefault(import("@typescript-eslint/parser")),
+ ] as const);
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(i => isPackageExists(i))
- const isUsingRemix = RemixPackages.some(i => isPackageExists(i))
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(i => isPackageExists(i));
+ const isUsingRemix = RemixPackages.some(i => isPackageExists(i));
- const { plugins } = pluginReact.configs.all
+ const { plugins } = pluginReact.configs.all;
return [
{
- name: 'antfu/react/setup',
+ name: "antfu/react/setup",
plugins: {
- '@eslint-react': plugins['@eslint-react'],
- '@eslint-react/dom': plugins['@eslint-react/dom'],
- 'react-hooks': pluginReactHooks,
- '@eslint-react/hooks-extra': plugins['@eslint-react/hooks-extra'],
- '@eslint-react/naming-convention': plugins['@eslint-react/naming-convention'],
- 'react-refresh': pluginReactRefresh,
+ "@eslint-react": plugins["@eslint-react"],
+ "@eslint-react/dom": plugins["@eslint-react/dom"],
+ "react-hooks": pluginReactHooks,
+ "@eslint-react/hooks-extra": plugins["@eslint-react/hooks-extra"],
+ "@eslint-react/naming-convention": plugins["@eslint-react/naming-convention"],
+ "react-refresh": pluginReactRefresh,
},
},
{
@@ -87,50 +87,50 @@ export async function react(
},
...isTypeAware ? { project: tsconfigPath } : {},
},
- sourceType: 'module',
+ sourceType: "module",
},
- name: 'antfu/react/rules',
+ name: "antfu/react/rules",
rules: {
// recommended rules from @eslint-react/dom
- '@eslint-react/dom/no-children-in-void-dom-elements': 'warn',
- '@eslint-react/dom/no-dangerously-set-innerhtml': 'warn',
- '@eslint-react/dom/no-dangerously-set-innerhtml-with-children': 'error',
- '@eslint-react/dom/no-find-dom-node': 'error',
- '@eslint-react/dom/no-missing-button-type': 'warn',
- '@eslint-react/dom/no-missing-iframe-sandbox': 'warn',
- '@eslint-react/dom/no-namespace': 'error',
- '@eslint-react/dom/no-render-return-value': 'error',
- '@eslint-react/dom/no-script-url': 'warn',
- '@eslint-react/dom/no-unsafe-iframe-sandbox': 'warn',
- '@eslint-react/dom/no-unsafe-target-blank': 'warn',
+ "@eslint-react/dom/no-children-in-void-dom-elements": "warn",
+ "@eslint-react/dom/no-dangerously-set-innerhtml": "warn",
+ "@eslint-react/dom/no-dangerously-set-innerhtml-with-children": "error",
+ "@eslint-react/dom/no-find-dom-node": "error",
+ "@eslint-react/dom/no-missing-button-type": "warn",
+ "@eslint-react/dom/no-missing-iframe-sandbox": "warn",
+ "@eslint-react/dom/no-namespace": "error",
+ "@eslint-react/dom/no-render-return-value": "error",
+ "@eslint-react/dom/no-script-url": "warn",
+ "@eslint-react/dom/no-unsafe-iframe-sandbox": "warn",
+ "@eslint-react/dom/no-unsafe-target-blank": "warn",
// recommended rules react-hooks
- 'react-hooks/exhaustive-deps': 'warn',
- 'react-hooks/rules-of-hooks': 'error',
+ "react-hooks/exhaustive-deps": "warn",
+ "react-hooks/rules-of-hooks": "error",
// react refresh
- 'react-refresh/only-export-components': [
- 'warn',
+ "react-refresh/only-export-components": [
+ "warn",
{
allowConstantExport: isAllowConstantExport,
allowExportNames: [
...(isUsingNext
? [
- 'config',
- 'generateStaticParams',
- 'metadata',
- 'generateMetadata',
- 'viewport',
- 'generateViewport',
+ "config",
+ "generateStaticParams",
+ "metadata",
+ "generateMetadata",
+ "viewport",
+ "generateViewport",
]
: []),
...(isUsingRemix
? [
- 'meta',
- 'links',
- 'headers',
- 'loader',
- 'action',
+ "meta",
+ "links",
+ "headers",
+ "loader",
+ "action",
]
: []),
],
@@ -138,46 +138,46 @@ export async function react(
],
// recommended rules from @eslint-react
- '@eslint-react/ensure-forward-ref-using-ref': 'warn',
- '@eslint-react/no-access-state-in-setstate': 'error',
- '@eslint-react/no-array-index-key': 'warn',
- '@eslint-react/no-children-count': 'warn',
- '@eslint-react/no-children-for-each': 'warn',
- '@eslint-react/no-children-map': 'warn',
- '@eslint-react/no-children-only': 'warn',
- '@eslint-react/no-children-prop': 'warn',
- '@eslint-react/no-children-to-array': 'warn',
- '@eslint-react/no-clone-element': 'warn',
- '@eslint-react/no-comment-textnodes': 'warn',
- '@eslint-react/no-component-will-mount': 'error',
- '@eslint-react/no-component-will-receive-props': 'error',
- '@eslint-react/no-component-will-update': 'error',
- '@eslint-react/no-create-ref': 'error',
- '@eslint-react/no-direct-mutation-state': 'error',
- '@eslint-react/no-duplicate-key': 'error',
- '@eslint-react/no-implicit-key': 'error',
- '@eslint-react/no-missing-key': 'error',
- '@eslint-react/no-nested-components': 'warn',
- '@eslint-react/no-redundant-should-component-update': 'error',
- '@eslint-react/no-set-state-in-component-did-mount': 'warn',
- '@eslint-react/no-set-state-in-component-did-update': 'warn',
- '@eslint-react/no-set-state-in-component-will-update': 'warn',
- '@eslint-react/no-string-refs': 'error',
- '@eslint-react/no-unsafe-component-will-mount': 'warn',
- '@eslint-react/no-unsafe-component-will-receive-props': 'warn',
- '@eslint-react/no-unsafe-component-will-update': 'warn',
- '@eslint-react/no-unstable-context-value': 'error',
- '@eslint-react/no-unstable-default-props': 'error',
- '@eslint-react/no-unused-class-component-members': 'warn',
- '@eslint-react/no-unused-state': 'warn',
- '@eslint-react/no-useless-fragment': 'warn',
- '@eslint-react/prefer-destructuring-assignment': 'warn',
- '@eslint-react/prefer-shorthand-boolean': 'warn',
- '@eslint-react/prefer-shorthand-fragment': 'warn',
+ "@eslint-react/ensure-forward-ref-using-ref": "warn",
+ "@eslint-react/no-access-state-in-setstate": "error",
+ "@eslint-react/no-array-index-key": "warn",
+ "@eslint-react/no-children-count": "warn",
+ "@eslint-react/no-children-for-each": "warn",
+ "@eslint-react/no-children-map": "warn",
+ "@eslint-react/no-children-only": "warn",
+ "@eslint-react/no-children-prop": "warn",
+ "@eslint-react/no-children-to-array": "warn",
+ "@eslint-react/no-clone-element": "warn",
+ "@eslint-react/no-comment-textnodes": "warn",
+ "@eslint-react/no-component-will-mount": "error",
+ "@eslint-react/no-component-will-receive-props": "error",
+ "@eslint-react/no-component-will-update": "error",
+ "@eslint-react/no-create-ref": "error",
+ "@eslint-react/no-direct-mutation-state": "error",
+ "@eslint-react/no-duplicate-key": "error",
+ "@eslint-react/no-implicit-key": "error",
+ "@eslint-react/no-missing-key": "error",
+ "@eslint-react/no-nested-components": "warn",
+ "@eslint-react/no-redundant-should-component-update": "error",
+ "@eslint-react/no-set-state-in-component-did-mount": "warn",
+ "@eslint-react/no-set-state-in-component-did-update": "warn",
+ "@eslint-react/no-set-state-in-component-will-update": "warn",
+ "@eslint-react/no-string-refs": "error",
+ "@eslint-react/no-unsafe-component-will-mount": "warn",
+ "@eslint-react/no-unsafe-component-will-receive-props": "warn",
+ "@eslint-react/no-unsafe-component-will-update": "warn",
+ "@eslint-react/no-unstable-context-value": "error",
+ "@eslint-react/no-unstable-default-props": "error",
+ "@eslint-react/no-unused-class-component-members": "warn",
+ "@eslint-react/no-unused-state": "warn",
+ "@eslint-react/no-useless-fragment": "warn",
+ "@eslint-react/prefer-destructuring-assignment": "warn",
+ "@eslint-react/prefer-shorthand-boolean": "warn",
+ "@eslint-react/prefer-shorthand-fragment": "warn",
...isTypeAware
? {
- '@eslint-react/no-leaked-conditional-rendering': 'warn',
+ "@eslint-react/no-leaked-conditional-rendering": "warn",
}
: {},
@@ -187,24 +187,24 @@ export async function react(
},
...fixupConfigRules(
compat.config({
- extends: ['plugin:ssr-friendly/recommended'],
+ extends: ["plugin:ssr-friendly/recommended"],
rules: {
- 'ssr-friendly/no-dom-globals-in-react-cc-render': 'off', // I don't use class components
+ "ssr-friendly/no-dom-globals-in-react-cc-render": "off", // I don't use class components
},
}),
),
...compat.config({
- extends: 'plugin:react/recommended',
+ extends: "plugin:react/recommended",
rules: {
// #region react
- 'react/jsx-no-leaked-render': [
- 'error',
- { validStrategies: ['ternary'] },
+ "react/jsx-no-leaked-render": [
+ "error",
+ { validStrategies: ["ternary"] },
],
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md
- 'react/jsx-sort-props': [
- 'error',
+ "react/jsx-sort-props": [
+ "error",
{
callbacksLast: true,
shorthandFirst: true,
@@ -214,43 +214,43 @@ export async function react(
reservedFirst: true,
},
],
- 'react/jsx-key': [
+ "react/jsx-key": [
1,
{ checkFragmentShorthand: true, checkKeyMustBeforeSpread: true },
],
- 'react/display-name': 0,
- 'react/prop-types': 0,
- 'react/jsx-pascal-case': [
+ "react/display-name": 0,
+ "react/prop-types": 0,
+ "react/jsx-pascal-case": [
2,
{
allowLeadingUnderscore: true,
allowNamespace: true,
},
],
- 'react/jsx-no-constructed-context-values': 2,
- 'react/jsx-no-useless-fragment': 2,
- 'react/jsx-handler-names': 2,
- 'react/jsx-no-duplicate-props': 2,
- 'react/jsx-curly-brace-presence': [
+ "react/jsx-no-constructed-context-values": 2,
+ "react/jsx-no-useless-fragment": 2,
+ "react/jsx-handler-names": 2,
+ "react/jsx-no-duplicate-props": 2,
+ "react/jsx-curly-brace-presence": [
2,
- { props: 'never', children: 'never' },
+ { props: "never", children: "never" },
],
// As of React 16.14 and 17
// https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#eslint
- 'react/react-in-jsx-scope': 0,
- 'react/jsx-uses-react': 0,
+ "react/react-in-jsx-scope": 0,
+ "react/jsx-uses-react": 0,
// #endregion react
},
}),
- ...compat.extends('plugin:react/jsx-runtime'),
+ ...compat.extends("plugin:react/jsx-runtime"),
...fixupConfigRules(
compat.extends(
- 'plugin:@next/next/recommended',
- 'plugin:@next/next/core-web-vitals',
+ "plugin:@next/next/recommended",
+ "plugin:@next/next/core-web-vitals",
),
),
...a11y(),
- ]
+ ];
}
diff --git a/src/configs/regexp.ts b/src/configs/regexp.ts
index 2926f7d5d7..dd0ef1606e 100644
--- a/src/configs/regexp.ts
+++ b/src/configs/regexp.ts
@@ -1,35 +1,35 @@
-import { configs } from 'eslint-plugin-regexp'
-import type { OptionsOverrides, OptionsRegExp, TypedFlatConfigItem } from '../types'
+import { configs } from "eslint-plugin-regexp";
+import type { OptionsOverrides, OptionsRegExp, TypedFlatConfigItem } from "../types";
-const nirOverridesConfig: TypedFlatConfigItem['rules'] = {
+const nirOverridesConfig: TypedFlatConfigItem["rules"] = {
// Nir's override
- 'regexp/strict': 'off', // conflicts with unicorn/better-regex https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1852
-}
+ "regexp/strict": "off", // conflicts with unicorn/better-regex https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1852
+};
export async function regexp(
options: OptionsRegExp & OptionsOverrides = {},
): Promise> {
- const config = configs['flat/recommended'] as TypedFlatConfigItem
+ const config = configs["flat/recommended"] as TypedFlatConfigItem;
const rules = {
...config.rules,
...nirOverridesConfig,
- }
+ };
- if (options.level === 'warn') {
+ if (options.level === "warn") {
for (const key in rules) {
- if (rules[key] === 'error')
- rules[key] = 'warn'
+ if (rules[key] === "error")
+ rules[key] = "warn";
}
}
return [
{
...config,
- name: 'nirtamir2/regexp/rules',
+ name: "nirtamir2/regexp/rules",
rules: {
...rules,
...options.overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/security.ts b/src/configs/security.ts
index 8af9341138..fd4b5d5aa7 100644
--- a/src/configs/security.ts
+++ b/src/configs/security.ts
@@ -1,15 +1,15 @@
-import { ensurePackages, interopDefault } from '../utils'
-import type { TypedFlatConfigItem } from '../types'
+import { ensurePackages, interopDefault } from "../utils";
+import type { TypedFlatConfigItem } from "../types";
export async function security(
): Promise> {
await ensurePackages([
- 'eslint-plugin-security',
- ])
+ "eslint-plugin-security",
+ ]);
// @ts-expect-error missing types
- const pluginSecurity = await interopDefault(import('eslint-plugin-security'))
+ const pluginSecurity = await interopDefault(import("eslint-plugin-security"));
return [
pluginSecurity.configs.recommended,
- ]
+ ];
}
diff --git a/src/configs/solid.ts b/src/configs/solid.ts
index 7b9a2601af..b523497602 100644
--- a/src/configs/solid.ts
+++ b/src/configs/solid.ts
@@ -1,7 +1,7 @@
-import { ensurePackages, interopDefault, toArray } from '../utils'
-import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from '../types'
-import { GLOB_JSX, GLOB_TSX } from '../globs'
-import { a11y } from './a11y'
+import { ensurePackages, interopDefault, toArray } from "../utils";
+import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from "../types";
+import { GLOB_JSX, GLOB_TSX } from "../globs";
+import { a11y } from "./a11y";
export async function solid(
options: OptionsHasTypeScript & OptionsOverrides & OptionsFiles & OptionsTypeScriptWithTypes = {},
@@ -10,28 +10,28 @@ export async function solid(
files = [GLOB_JSX, GLOB_TSX],
overrides = {},
typescript = true,
- } = options
+ } = options;
await ensurePackages([
- 'eslint-plugin-solid',
- ])
+ "eslint-plugin-solid",
+ ]);
const tsconfigPath = options?.tsconfigPath
? toArray(options.tsconfigPath)
- : undefined
- const isTypeAware = Boolean(tsconfigPath)
+ : undefined;
+ const isTypeAware = Boolean(tsconfigPath);
const [
pluginSolid,
parserTs,
] = await Promise.all([
- interopDefault(import('eslint-plugin-solid')),
- interopDefault(import('@typescript-eslint/parser')),
- ] as const)
+ interopDefault(import("eslint-plugin-solid")),
+ interopDefault(import("@typescript-eslint/parser")),
+ ] as const);
return [
{
- name: 'antfu/solid/setup',
+ name: "antfu/solid/setup",
plugins: {
solid: pluginSolid,
},
@@ -46,39 +46,39 @@ export async function solid(
},
...isTypeAware ? { project: tsconfigPath } : {},
},
- sourceType: 'module',
+ sourceType: "module",
},
- name: 'antfu/solid/rules',
+ name: "antfu/solid/rules",
rules: {
// reactivity
- 'solid/components-return-once': 'warn',
- 'solid/event-handlers': ['error', {
+ "solid/components-return-once": "warn",
+ "solid/event-handlers": ["error", {
// if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
ignoreCase: false,
// if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
warnOnSpread: false,
}],
// these rules are mostly style suggestions
- 'solid/imports': 'error',
+ "solid/imports": "error",
// identifier usage is important
- 'solid/jsx-no-duplicate-props': 'error',
- 'solid/jsx-no-script-url': 'error',
- 'solid/jsx-no-undef': 'error',
- 'solid/jsx-uses-vars': 'error',
- 'solid/no-destructure': 'error',
+ "solid/jsx-no-duplicate-props": "error",
+ "solid/jsx-no-script-url": "error",
+ "solid/jsx-no-undef": "error",
+ "solid/jsx-uses-vars": "error",
+ "solid/no-destructure": "error",
// security problems
- 'solid/no-innerhtml': ['error', { allowStatic: true }],
- 'solid/no-react-deps': 'error',
- 'solid/no-react-specific-props': 'error',
- 'solid/no-unknown-namespaces': 'error',
- 'solid/prefer-for': 'error',
- 'solid/reactivity': 'warn',
- 'solid/self-closing-comp': 'error',
- 'solid/style-prop': ['error', { styleProps: ['style', 'css'] }],
+ "solid/no-innerhtml": ["error", { allowStatic: true }],
+ "solid/no-react-deps": "error",
+ "solid/no-react-specific-props": "error",
+ "solid/no-unknown-namespaces": "error",
+ "solid/prefer-for": "error",
+ "solid/reactivity": "warn",
+ "solid/self-closing-comp": "error",
+ "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
...typescript
? {
- 'solid/jsx-no-undef': ['error', { typescriptEnabled: true }],
- 'solid/no-unknown-namespaces': 'off',
+ "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
+ "solid/no-unknown-namespaces": "off",
}
: {},
// overrides
@@ -86,5 +86,5 @@ export async function solid(
},
},
...a11y(),
- ]
+ ];
}
diff --git a/src/configs/sort.ts b/src/configs/sort.ts
index e65879e313..782ac61afa 100644
--- a/src/configs/sort.ts
+++ b/src/configs/sort.ts
@@ -1,4 +1,4 @@
-import type { TypedFlatConfigItem } from '../types'
+import type { TypedFlatConfigItem } from "../types";
/**
* Sort package.json
@@ -8,103 +8,103 @@ import type { TypedFlatConfigItem } from '../types'
export async function sortPackageJson(): Promise> {
return [
{
- files: ['**/package.json'],
- name: 'antfu/sort/package-json',
+ files: ["**/package.json"],
+ name: "antfu/sort/package-json",
rules: {
- 'jsonc/sort-array-values': [
- 'error',
+ "jsonc/sort-array-values": [
+ "error",
{
- order: { type: 'asc' },
- pathPattern: '^files$',
+ order: { type: "asc" },
+ pathPattern: "^files$",
},
],
- 'jsonc/sort-keys': [
- 'error',
+ "jsonc/sort-keys": [
+ "error",
{
order: [
- 'publisher',
- 'name',
- 'displayName',
- 'type',
- 'version',
- 'private',
- 'packageManager',
- 'description',
- 'author',
- 'license',
- 'funding',
- 'homepage',
- 'repository',
- 'bugs',
- 'keywords',
- 'categories',
- 'sideEffects',
- 'exports',
- 'main',
- 'module',
- 'unpkg',
- 'jsdelivr',
- 'types',
- 'typesVersions',
- 'bin',
- 'icon',
- 'files',
- 'engines',
- 'activationEvents',
- 'contributes',
- 'scripts',
- 'peerDependencies',
- 'peerDependenciesMeta',
- 'dependencies',
- 'optionalDependencies',
- 'devDependencies',
- 'pnpm',
- 'overrides',
- 'resolutions',
- 'husky',
- 'simple-git-hooks',
- 'lint-staged',
- 'eslintConfig',
+ "publisher",
+ "name",
+ "displayName",
+ "type",
+ "version",
+ "private",
+ "packageManager",
+ "description",
+ "author",
+ "license",
+ "funding",
+ "homepage",
+ "repository",
+ "bugs",
+ "keywords",
+ "categories",
+ "sideEffects",
+ "exports",
+ "main",
+ "module",
+ "unpkg",
+ "jsdelivr",
+ "types",
+ "typesVersions",
+ "bin",
+ "icon",
+ "files",
+ "engines",
+ "activationEvents",
+ "contributes",
+ "scripts",
+ "peerDependencies",
+ "peerDependenciesMeta",
+ "dependencies",
+ "optionalDependencies",
+ "devDependencies",
+ "pnpm",
+ "overrides",
+ "resolutions",
+ "husky",
+ "simple-git-hooks",
+ "lint-staged",
+ "eslintConfig",
],
- pathPattern: '^$',
+ pathPattern: "^$",
},
{
- order: { type: 'asc' },
- pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$',
+ order: { type: "asc" },
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$",
},
{
- order: { type: 'asc' },
- pathPattern: '^(?:resolutions|overrides|pnpm.overrides)$',
+ order: { type: "asc" },
+ pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$",
},
{
order: [
- 'types',
- 'import',
- 'require',
- 'default',
+ "types",
+ "import",
+ "require",
+ "default",
],
- pathPattern: '^exports.*$',
+ pathPattern: "^exports.*$",
},
{
order: [
// client hooks only
- 'pre-commit',
- 'prepare-commit-msg',
- 'commit-msg',
- 'post-commit',
- 'pre-rebase',
- 'post-rewrite',
- 'post-checkout',
- 'post-merge',
- 'pre-push',
- 'pre-auto-gc',
+ "pre-commit",
+ "prepare-commit-msg",
+ "commit-msg",
+ "post-commit",
+ "pre-rebase",
+ "post-rewrite",
+ "post-checkout",
+ "post-merge",
+ "pre-push",
+ "pre-auto-gc",
],
- pathPattern: '^(?:gitHooks|husky|simple-git-hooks)$',
+ pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$",
},
],
},
},
- ]
+ ];
}
/**
* Sort tsconfig.json
@@ -115,125 +115,125 @@ export async function sortPackageJson(): Promise> {
export function sortTsconfig(): Array {
return [
{
- files: ['**/tsconfig.json', '**/tsconfig.*.json'],
- name: 'antfu/sort/tsconfig-json',
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
+ name: "antfu/sort/tsconfig-json",
rules: {
- 'jsonc/sort-keys': [
- 'error',
+ "jsonc/sort-keys": [
+ "error",
{
order: [
- 'extends',
- 'compilerOptions',
- 'references',
- 'files',
- 'include',
- 'exclude',
+ "extends",
+ "compilerOptions",
+ "references",
+ "files",
+ "include",
+ "exclude",
],
- pathPattern: '^$',
+ pathPattern: "^$",
},
{
order: [
/* Projects */
- 'incremental',
- 'composite',
- 'tsBuildInfoFile',
- 'disableSourceOfProjectReferenceRedirect',
- 'disableSolutionSearching',
- 'disableReferencedProjectLoad',
+ "incremental",
+ "composite",
+ "tsBuildInfoFile",
+ "disableSourceOfProjectReferenceRedirect",
+ "disableSolutionSearching",
+ "disableReferencedProjectLoad",
/* Language and Environment */
- 'target',
- 'jsx',
- 'jsxFactory',
- 'jsxFragmentFactory',
- 'jsxImportSource',
- 'lib',
- 'moduleDetection',
- 'noLib',
- 'reactNamespace',
- 'useDefineForClassFields',
- 'emitDecoratorMetadata',
- 'experimentalDecorators',
+ "target",
+ "jsx",
+ "jsxFactory",
+ "jsxFragmentFactory",
+ "jsxImportSource",
+ "lib",
+ "moduleDetection",
+ "noLib",
+ "reactNamespace",
+ "useDefineForClassFields",
+ "emitDecoratorMetadata",
+ "experimentalDecorators",
/* Modules */
- 'baseUrl',
- 'rootDir',
- 'rootDirs',
- 'customConditions',
- 'module',
- 'moduleResolution',
- 'moduleSuffixes',
- 'noResolve',
- 'paths',
- 'resolveJsonModule',
- 'resolvePackageJsonExports',
- 'resolvePackageJsonImports',
- 'typeRoots',
- 'types',
- 'allowArbitraryExtensions',
- 'allowImportingTsExtensions',
- 'allowUmdGlobalAccess',
+ "baseUrl",
+ "rootDir",
+ "rootDirs",
+ "customConditions",
+ "module",
+ "moduleResolution",
+ "moduleSuffixes",
+ "noResolve",
+ "paths",
+ "resolveJsonModule",
+ "resolvePackageJsonExports",
+ "resolvePackageJsonImports",
+ "typeRoots",
+ "types",
+ "allowArbitraryExtensions",
+ "allowImportingTsExtensions",
+ "allowUmdGlobalAccess",
/* JavaScript Support */
- 'allowJs',
- 'checkJs',
- 'maxNodeModuleJsDepth',
+ "allowJs",
+ "checkJs",
+ "maxNodeModuleJsDepth",
/* Type Checking */
- 'strict',
- 'strictBindCallApply',
- 'strictFunctionTypes',
- 'strictNullChecks',
- 'strictPropertyInitialization',
- 'allowUnreachableCode',
- 'allowUnusedLabels',
- 'alwaysStrict',
- 'exactOptionalPropertyTypes',
- 'noFallthroughCasesInSwitch',
- 'noImplicitAny',
- 'noImplicitOverride',
- 'noImplicitReturns',
- 'noImplicitThis',
- 'noPropertyAccessFromIndexSignature',
- 'noUncheckedIndexedAccess',
- 'noUnusedLocals',
- 'noUnusedParameters',
- 'useUnknownInCatchVariables',
+ "strict",
+ "strictBindCallApply",
+ "strictFunctionTypes",
+ "strictNullChecks",
+ "strictPropertyInitialization",
+ "allowUnreachableCode",
+ "allowUnusedLabels",
+ "alwaysStrict",
+ "exactOptionalPropertyTypes",
+ "noFallthroughCasesInSwitch",
+ "noImplicitAny",
+ "noImplicitOverride",
+ "noImplicitReturns",
+ "noImplicitThis",
+ "noPropertyAccessFromIndexSignature",
+ "noUncheckedIndexedAccess",
+ "noUnusedLocals",
+ "noUnusedParameters",
+ "useUnknownInCatchVariables",
/* Emit */
- 'declaration',
- 'declarationDir',
- 'declarationMap',
- 'downlevelIteration',
- 'emitBOM',
- 'emitDeclarationOnly',
- 'importHelpers',
- 'importsNotUsedAsValues',
- 'inlineSourceMap',
- 'inlineSources',
- 'mapRoot',
- 'newLine',
- 'noEmit',
- 'noEmitHelpers',
- 'noEmitOnError',
- 'outDir',
- 'outFile',
- 'preserveConstEnums',
- 'preserveValueImports',
- 'removeComments',
- 'sourceMap',
- 'sourceRoot',
- 'stripInternal',
+ "declaration",
+ "declarationDir",
+ "declarationMap",
+ "downlevelIteration",
+ "emitBOM",
+ "emitDeclarationOnly",
+ "importHelpers",
+ "importsNotUsedAsValues",
+ "inlineSourceMap",
+ "inlineSources",
+ "mapRoot",
+ "newLine",
+ "noEmit",
+ "noEmitHelpers",
+ "noEmitOnError",
+ "outDir",
+ "outFile",
+ "preserveConstEnums",
+ "preserveValueImports",
+ "removeComments",
+ "sourceMap",
+ "sourceRoot",
+ "stripInternal",
/* Interop Constraints */
- 'allowSyntheticDefaultImports',
- 'esModuleInterop',
- 'forceConsistentCasingInFileNames',
- 'isolatedModules',
- 'preserveSymlinks',
- 'verbatimModuleSyntax',
+ "allowSyntheticDefaultImports",
+ "esModuleInterop",
+ "forceConsistentCasingInFileNames",
+ "isolatedModules",
+ "preserveSymlinks",
+ "verbatimModuleSyntax",
/* Completeness */
- 'skipDefaultLibCheck',
- 'skipLibCheck',
+ "skipDefaultLibCheck",
+ "skipLibCheck",
],
- pathPattern: '^compilerOptions$',
+ pathPattern: "^compilerOptions$",
},
],
},
},
- ]
+ ];
}
diff --git a/src/configs/storybook.ts b/src/configs/storybook.ts
index 2dafe8373b..09a7ebe287 100644
--- a/src/configs/storybook.ts
+++ b/src/configs/storybook.ts
@@ -1,32 +1,32 @@
-import { ensurePackages } from '../utils'
-import type { TypedFlatConfigItem } from '../types'
-import { fixupConfigRules } from '@eslint/compat'
-import { compat } from '../compat'
+import { ensurePackages } from "../utils";
+import type { TypedFlatConfigItem } from "../types";
+import { fixupConfigRules } from "@eslint/compat";
+import { compat } from "../compat";
export async function storybook(
): Promise> {
await ensurePackages([
- 'eslint-plugin-storybook',
- ])
+ "eslint-plugin-storybook",
+ ]);
return [{
- name: 'nirtamir2/storybook',
+ name: "nirtamir2/storybook",
...fixupConfigRules(
compat.config({
extends: [
- 'plugin:storybook/recommended',
- 'plugin:storybook/csf-strict',
- 'plugin:storybook/addon-interactions',
+ "plugin:storybook/recommended",
+ "plugin:storybook/csf-strict",
+ "plugin:storybook/addon-interactions",
],
// .eslintignore is not supported with flat config, make sure to ignore also other build and test folders
- ignorePatterns: ['!.storybook', 'storybook-static'],
+ ignorePatterns: ["!.storybook", "storybook-static"],
}),
),
}, {
- name: 'nirtamir2/storybook/i18n',
- files: ['**.stories.tsx'],
+ name: "nirtamir2/storybook/i18n",
+ files: ["**.stories.tsx"],
rules: {
- 'i18next/no-string-literal': 'off',
+ "i18next/no-string-literal": "off",
},
- }]
+ }];
}
diff --git a/src/configs/stylistic.ts b/src/configs/stylistic.ts
index 2417a67930..4a19082e56 100644
--- a/src/configs/stylistic.ts
+++ b/src/configs/stylistic.ts
@@ -1,18 +1,16 @@
-import { interopDefault } from '../utils'
-import type { OptionsOverrides, StylisticConfig, TypedFlatConfigItem } from '../types'
-import { pluginAntfu } from '../plugins'
+import { interopDefault } from "../utils";
+import type { OptionsOverrides, StylisticConfig, TypedFlatConfigItem } from "../types";
+import { pluginAntfu } from "../plugins";
export const StylisticConfigDefaults: StylisticConfig = {
indent: 2,
jsx: true,
- // TODO-nir: quotes: "double",
- quotes: 'single',
- // TODO-nir semi: true,
- semi: false,
-}
+ quotes: "double",
+ semi: true,
+};
export interface StylisticOptions extends StylisticConfig, OptionsOverrides {
- lessOpinionated?: boolean
+ lessOpinionated?: boolean;
}
export async function stylistic(
@@ -28,22 +26,22 @@ export async function stylistic(
} = {
...StylisticConfigDefaults,
...options,
- }
+ };
- const pluginStylistic = await interopDefault(import('@stylistic/eslint-plugin'))
+ const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
const config = pluginStylistic.configs.customize({
flat: true,
indent,
jsx,
- pluginName: 'style',
+ pluginName: "style",
quotes,
semi,
- })
+ });
return [
{
- name: 'antfu/stylistic/rules',
+ name: "antfu/stylistic/rules",
plugins: {
antfu: pluginAntfu,
style: pluginStylistic,
@@ -51,21 +49,21 @@ export async function stylistic(
rules: {
...config.rules,
- 'antfu/consistent-list-newline': 'error',
+ "antfu/consistent-list-newline": "error",
...(lessOpinionated
? {
- curly: ['error', 'all'],
+ curly: ["error", "all"],
}
: {
- 'antfu/curly': 'error',
- 'antfu/if-newline': 'error',
- 'antfu/top-level-function': 'error',
+ "antfu/curly": "error",
+ "antfu/if-newline": "error",
+ "antfu/top-level-function": "error",
}
),
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/svelte.ts b/src/configs/svelte.ts
index a4a7f193bf..832eeb9b9e 100644
--- a/src/configs/svelte.ts
+++ b/src/configs/svelte.ts
@@ -1,6 +1,6 @@
-import { ensurePackages, interopDefault } from '../utils'
-import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types'
-import { GLOB_SVELTE } from '../globs'
+import { ensurePackages, interopDefault } from "../utils";
+import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from "../types";
+import { GLOB_SVELTE } from "../globs";
export async function svelte(
options: OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles = {},
@@ -9,28 +9,28 @@ export async function svelte(
files = [GLOB_SVELTE],
overrides = {},
stylistic = true,
- } = options
+ } = options;
const {
indent = 2,
- quotes = 'single',
- } = typeof stylistic === 'boolean' ? {} : stylistic
+ quotes = "single",
+ } = typeof stylistic === "boolean" ? {} : stylistic;
await ensurePackages([
- 'eslint-plugin-svelte',
- ])
+ "eslint-plugin-svelte",
+ ]);
const [
pluginSvelte,
parserSvelte,
] = await Promise.all([
- interopDefault(import('eslint-plugin-svelte')),
- interopDefault(import('svelte-eslint-parser')),
- ] as const)
+ interopDefault(import("eslint-plugin-svelte")),
+ interopDefault(import("svelte-eslint-parser")),
+ ] as const);
return [
{
- name: 'antfu/svelte/setup',
+ name: "antfu/svelte/setup",
plugins: {
svelte: pluginSvelte,
},
@@ -40,69 +40,69 @@ export async function svelte(
languageOptions: {
parser: parserSvelte,
parserOptions: {
- extraFileExtensions: ['.svelte'],
+ extraFileExtensions: [".svelte"],
parser: options.typescript
- ? await interopDefault(import('@typescript-eslint/parser')) as any
+ ? await interopDefault(import("@typescript-eslint/parser")) as any
: null,
},
},
- name: 'antfu/svelte/rules',
- processor: pluginSvelte.processors['.svelte'],
+ name: "antfu/svelte/rules",
+ processor: pluginSvelte.processors[".svelte"],
rules: {
- 'import/no-mutable-exports': 'off',
- 'no-undef': 'off', // incompatible with most recent (attribute-form) generic types RFC
- 'no-unused-vars': ['error', {
- args: 'none',
- caughtErrors: 'none',
+ "import/no-mutable-exports": "off",
+ "no-undef": "off", // incompatible with most recent (attribute-form) generic types RFC
+ "no-unused-vars": ["error", {
+ args: "none",
+ caughtErrors: "none",
ignoreRestSiblings: true,
- vars: 'all',
+ vars: "all",
varsIgnorePattern: String.raw`^(\$\$Props$|\$\$Events$|\$\$Slots$)`,
}],
- 'svelte/comment-directive': 'error',
- 'svelte/no-at-debug-tags': 'warn',
- 'svelte/no-at-html-tags': 'error',
- 'svelte/no-dupe-else-if-blocks': 'error',
- 'svelte/no-dupe-style-properties': 'error',
- 'svelte/no-dupe-use-directives': 'error',
- 'svelte/no-dynamic-slot-name': 'error',
- 'svelte/no-export-load-in-svelte-module-in-kit-pages': 'error',
- 'svelte/no-inner-declarations': 'error',
- 'svelte/no-not-function-handler': 'error',
- 'svelte/no-object-in-text-mustaches': 'error',
- 'svelte/no-reactive-functions': 'error',
- 'svelte/no-reactive-literals': 'error',
- 'svelte/no-shorthand-style-property-overrides': 'error',
- 'svelte/no-unknown-style-directive-property': 'error',
- 'svelte/no-unused-svelte-ignore': 'error',
- 'svelte/no-useless-mustaches': 'error',
- 'svelte/require-store-callbacks-use-set-param': 'error',
- 'svelte/system': 'error',
- 'svelte/valid-compile': 'error',
- 'svelte/valid-each-key': 'error',
+ "svelte/comment-directive": "error",
+ "svelte/no-at-debug-tags": "warn",
+ "svelte/no-at-html-tags": "error",
+ "svelte/no-dupe-else-if-blocks": "error",
+ "svelte/no-dupe-style-properties": "error",
+ "svelte/no-dupe-use-directives": "error",
+ "svelte/no-dynamic-slot-name": "error",
+ "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
+ "svelte/no-inner-declarations": "error",
+ "svelte/no-not-function-handler": "error",
+ "svelte/no-object-in-text-mustaches": "error",
+ "svelte/no-reactive-functions": "error",
+ "svelte/no-reactive-literals": "error",
+ "svelte/no-shorthand-style-property-overrides": "error",
+ "svelte/no-unknown-style-directive-property": "error",
+ "svelte/no-unused-svelte-ignore": "error",
+ "svelte/no-useless-mustaches": "error",
+ "svelte/require-store-callbacks-use-set-param": "error",
+ "svelte/system": "error",
+ "svelte/valid-compile": "error",
+ "svelte/valid-each-key": "error",
- 'unused-imports/no-unused-vars': [
- 'error',
- { args: 'after-used', argsIgnorePattern: '^_', vars: 'all', varsIgnorePattern: String.raw`^(_|\$\$Props$|\$\$Events$|\$\$Slots$)` },
+ "unused-imports/no-unused-vars": [
+ "error",
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: String.raw`^(_|\$\$Props$|\$\$Events$|\$\$Slots$)` },
],
...stylistic
? {
- '@stylistic/indent': 'off', // superseded by svelte/indent
- '@stylistic/no-trailing-spaces': 'off', // superseded by svelte/no-trailing-spaces
- 'svelte/derived-has-same-inputs-outputs': 'error',
- 'svelte/html-closing-bracket-spacing': 'error',
- 'svelte/html-quotes': ['error', { prefer: quotes }],
- 'svelte/indent': ['error', { alignAttributesVertically: true, indent }],
- 'svelte/mustache-spacing': 'error',
- 'svelte/no-spaces-around-equal-signs-in-attribute': 'error',
- 'svelte/no-trailing-spaces': 'error',
- 'svelte/spaced-html-comment': 'error',
+ "@stylistic/indent": "off", // superseded by svelte/indent
+ "@stylistic/no-trailing-spaces": "off", // superseded by svelte/no-trailing-spaces
+ "svelte/derived-has-same-inputs-outputs": "error",
+ "svelte/html-closing-bracket-spacing": "error",
+ "svelte/html-quotes": ["error", { prefer: quotes }],
+ "svelte/indent": ["error", { alignAttributesVertically: true, indent }],
+ "svelte/mustache-spacing": "error",
+ "svelte/no-spaces-around-equal-signs-in-attribute": "error",
+ "svelte/no-trailing-spaces": "error",
+ "svelte/spaced-html-comment": "error",
}
: {},
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/tailwindcss.ts b/src/configs/tailwindcss.ts
index ef30dc663d..8854a2c5ad 100644
--- a/src/configs/tailwindcss.ts
+++ b/src/configs/tailwindcss.ts
@@ -1,13 +1,13 @@
-import { ensurePackages, interopDefault } from '../utils'
-import type { TypedFlatConfigItem } from '../types'
+import { ensurePackages, interopDefault } from "../utils";
+import type { TypedFlatConfigItem } from "../types";
export async function tailwindcss(
): Promise> {
await ensurePackages([
- 'eslint-plugin-tailwindcss',
- ])
+ "eslint-plugin-tailwindcss",
+ ]);
- const pluginTailwindCSS = await interopDefault(import('eslint-plugin-tailwindcss'))
+ const pluginTailwindCSS = await interopDefault(import("eslint-plugin-tailwindcss"));
- return pluginTailwindCSS.configs['flat/recommended']
+ return pluginTailwindCSS.configs["flat/recommended"];
}
diff --git a/src/configs/test.ts b/src/configs/test.ts
index 22d204af14..314f1ff6b9 100644
--- a/src/configs/test.ts
+++ b/src/configs/test.ts
@@ -1,9 +1,9 @@
-import { interopDefault } from '../utils'
-import type { OptionsFiles, OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from '../types'
-import { GLOB_TESTS } from '../globs'
+import { interopDefault } from "../utils";
+import type { OptionsFiles, OptionsIsInEditor, OptionsOverrides, TypedFlatConfigItem } from "../types";
+import { GLOB_TESTS } from "../globs";
// Hold the reference so we don't redeclare the plugin on each call
-let _pluginTest: any
+let _pluginTest: any;
export async function test(
options: OptionsFiles & OptionsIsInEditor & OptionsOverrides = {},
@@ -12,16 +12,16 @@ export async function test(
files = GLOB_TESTS,
isInEditor = false,
overrides = {},
- } = options
+ } = options;
const [
pluginVitest,
pluginNoOnlyTests,
] = await Promise.all([
- interopDefault(import('eslint-plugin-vitest')),
+ interopDefault(import("eslint-plugin-vitest")),
// @ts-expect-error missing types
- interopDefault(import('eslint-plugin-no-only-tests')),
- ] as const)
+ interopDefault(import("eslint-plugin-no-only-tests")),
+ ] as const);
_pluginTest = _pluginTest || {
...pluginVitest,
@@ -30,30 +30,30 @@ export async function test(
// extend `vitest/no-only-tests` rule
...pluginNoOnlyTests.rules,
},
- }
+ };
return [
{
- name: 'antfu/vitest/setup',
+ name: "antfu/vitest/setup",
plugins: {
vitest: _pluginTest,
},
},
{
files,
- name: 'antfu/test/rules',
+ name: "antfu/test/rules",
rules: {
- 'n/prefer-global/process': 'off',
+ "n/prefer-global/process": "off",
- 'vitest/consistent-test-it': ['error', { fn: 'it', withinDescribe: 'it' }],
- 'vitest/no-identical-title': 'error',
- 'vitest/no-import-node-test': 'error',
- 'vitest/no-only-tests': isInEditor ? 'off' : 'error',
- 'vitest/prefer-hooks-in-order': 'error',
- 'vitest/prefer-lowercase-title': 'error',
+ "vitest/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
+ "vitest/no-identical-title": "error",
+ "vitest/no-import-node-test": "error",
+ "vitest/no-only-tests": isInEditor ? "off" : "error",
+ "vitest/prefer-hooks-in-order": "error",
+ "vitest/prefer-lowercase-title": "error",
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/toml.ts b/src/configs/toml.ts
index 296fabd93a..f27fe935d4 100644
--- a/src/configs/toml.ts
+++ b/src/configs/toml.ts
@@ -1,6 +1,6 @@
-import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types'
-import { GLOB_TOML } from '../globs'
-import { interopDefault } from '../utils'
+import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from "../types";
+import { GLOB_TOML } from "../globs";
+import { interopDefault } from "../utils";
export async function toml(
options: OptionsOverrides & OptionsStylistic & OptionsFiles = {},
@@ -9,23 +9,23 @@ export async function toml(
files = [GLOB_TOML],
overrides = {},
stylistic = true,
- } = options
+ } = options;
const {
indent = 2,
- } = typeof stylistic === 'boolean' ? {} : stylistic
+ } = typeof stylistic === "boolean" ? {} : stylistic;
const [
pluginToml,
parserToml,
] = await Promise.all([
- interopDefault(import('eslint-plugin-toml')),
- interopDefault(import('toml-eslint-parser')),
- ] as const)
+ interopDefault(import("eslint-plugin-toml")),
+ interopDefault(import("toml-eslint-parser")),
+ ] as const);
return [
{
- name: 'antfu/toml/setup',
+ name: "antfu/toml/setup",
plugins: {
toml: pluginToml,
},
@@ -35,38 +35,38 @@ export async function toml(
languageOptions: {
parser: parserToml,
},
- name: 'antfu/toml/rules',
+ name: "antfu/toml/rules",
rules: {
- '@stylistic/spaced-comment': 'off',
+ "@stylistic/spaced-comment": "off",
- 'toml/comma-style': 'error',
- 'toml/keys-order': 'error',
- 'toml/no-space-dots': 'error',
- 'toml/no-unreadable-number-separator': 'error',
- 'toml/precision-of-fractional-seconds': 'error',
- 'toml/precision-of-integer': 'error',
- 'toml/tables-order': 'error',
+ "toml/comma-style": "error",
+ "toml/keys-order": "error",
+ "toml/no-space-dots": "error",
+ "toml/no-unreadable-number-separator": "error",
+ "toml/precision-of-fractional-seconds": "error",
+ "toml/precision-of-integer": "error",
+ "toml/tables-order": "error",
- 'toml/vue-custom-block/no-parsing-error': 'error',
+ "toml/vue-custom-block/no-parsing-error": "error",
...stylistic
? {
- 'toml/array-bracket-newline': 'error',
- 'toml/array-bracket-spacing': 'error',
- 'toml/array-element-newline': 'error',
- 'toml/indent': ['error', indent === 'tab' ? 2 : indent],
- 'toml/inline-table-curly-spacing': 'error',
- 'toml/key-spacing': 'error',
- 'toml/padding-line-between-pairs': 'error',
- 'toml/padding-line-between-tables': 'error',
- 'toml/quoted-keys': 'error',
- 'toml/spaced-comment': 'error',
- 'toml/table-bracket-spacing': 'error',
+ "toml/array-bracket-newline": "error",
+ "toml/array-bracket-spacing": "error",
+ "toml/array-element-newline": "error",
+ "toml/indent": ["error", indent === "tab" ? 2 : indent],
+ "toml/inline-table-curly-spacing": "error",
+ "toml/key-spacing": "error",
+ "toml/padding-line-between-pairs": "error",
+ "toml/padding-line-between-tables": "error",
+ "toml/quoted-keys": "error",
+ "toml/spaced-comment": "error",
+ "toml/table-bracket-spacing": "error",
}
: {},
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts
index e39134c029..edf2ecff68 100644
--- a/src/configs/typescript.ts
+++ b/src/configs/typescript.ts
@@ -1,5 +1,5 @@
-import process from 'node:process'
-import { GLOB_SRC, GLOB_TS, GLOB_TSX } from '../globs'
+import process from "node:process";
+import { GLOB_SRC, GLOB_TS, GLOB_TSX } from "../globs";
import type {
OptionsComponentExts,
OptionsFiles,
@@ -7,12 +7,12 @@ import type {
OptionsTypeScriptParserOptions,
OptionsTypeScriptWithTypes,
TypedFlatConfigItem,
-} from '../types'
-import { pluginAntfu } from '../plugins'
-import { interopDefault, toArray } from '../utils'
-import expectType from 'eslint-plugin-expect-type/configs/recommended'
-import tseslint from 'typescript-eslint'
-import { compat } from '../compat'
+} from "../types";
+import { pluginAntfu } from "../plugins";
+import { interopDefault, toArray } from "../utils";
+import expectType from "eslint-plugin-expect-type/configs/recommended";
+import tseslint from "typescript-eslint";
+import { compat } from "../compat";
export async function typescript(
options: OptionsFiles & OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions = {},
@@ -21,49 +21,49 @@ export async function typescript(
componentExts = [],
overrides = {},
parserOptions = {},
- } = options
+ } = options;
const files = options.files ?? [
GLOB_SRC,
...componentExts.map(ext => `**/*.${ext}`),
- ]
+ ];
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX]
+ const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
const tsconfigPath = options?.tsconfigPath
? toArray(options.tsconfigPath)
- : undefined
- const isTypeAware = Boolean(tsconfigPath)
+ : undefined;
+ const isTypeAware = Boolean(tsconfigPath);
- const typeAwareRules: TypedFlatConfigItem['rules'] = {
- 'dot-notation': 'off',
- 'no-implied-eval': 'off',
- 'no-throw-literal': 'off',
- '@typescript-eslint/await-thenable': 'error',
- '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
- '@typescript-eslint/no-floating-promises': 'error',
- '@typescript-eslint/no-for-in-array': 'error',
- '@typescript-eslint/no-implied-eval': 'error',
- '@typescript-eslint/no-misused-promises': 'error',
- '@typescript-eslint/no-throw-literal': 'error',
- '@typescript-eslint/no-unnecessary-type-assertion': 'error',
- '@typescript-eslint/no-unsafe-argument': 'error',
- '@typescript-eslint/no-unsafe-assignment': 'error',
- '@typescript-eslint/no-unsafe-call': 'error',
- '@typescript-eslint/no-unsafe-member-access': 'error',
- '@typescript-eslint/no-unsafe-return': 'error',
- '@typescript-eslint/restrict-plus-operands': 'error',
- '@typescript-eslint/restrict-template-expressions': 'error',
- '@typescript-eslint/strict-boolean-expressions': 'error',
- '@typescript-eslint/unbound-method': 'error',
- }
+ const typeAwareRules: TypedFlatConfigItem["rules"] = {
+ "dot-notation": "off",
+ "no-implied-eval": "off",
+ "no-throw-literal": "off",
+ "@typescript-eslint/await-thenable": "error",
+ "@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
+ "@typescript-eslint/no-floating-promises": "error",
+ "@typescript-eslint/no-for-in-array": "error",
+ "@typescript-eslint/no-implied-eval": "error",
+ "@typescript-eslint/no-misused-promises": "error",
+ "@typescript-eslint/no-throw-literal": "error",
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
+ "@typescript-eslint/no-unsafe-argument": "error",
+ "@typescript-eslint/no-unsafe-assignment": "error",
+ "@typescript-eslint/no-unsafe-call": "error",
+ "@typescript-eslint/no-unsafe-member-access": "error",
+ "@typescript-eslint/no-unsafe-return": "error",
+ "@typescript-eslint/restrict-plus-operands": "error",
+ "@typescript-eslint/restrict-template-expressions": "error",
+ "@typescript-eslint/strict-boolean-expressions": "error",
+ "@typescript-eslint/unbound-method": "error",
+ };
const [
pluginTs,
parserTs,
] = await Promise.all([
- interopDefault(import('@typescript-eslint/eslint-plugin')),
- interopDefault(import('@typescript-eslint/parser')),
- ] as const)
+ interopDefault(import("@typescript-eslint/eslint-plugin")),
+ interopDefault(import("@typescript-eslint/parser")),
+ ] as const);
function makeParser(typeAware: boolean, files: Array, ignores?: Array): TypedFlatConfigItem {
return {
@@ -73,7 +73,7 @@ export async function typescript(
parser: parserTs,
parserOptions: {
extraFileExtensions: componentExts.map(ext => `.${ext}`),
- sourceType: 'module',
+ sourceType: "module",
...typeAware
? {
project: tsconfigPath,
@@ -83,14 +83,14 @@ export async function typescript(
...parserOptions as any,
},
},
- name: `antfu/typescript/${typeAware ? 'type-aware-parser' : 'parser'}`,
- }
+ name: `antfu/typescript/${typeAware ? "type-aware-parser" : "parser"}`,
+ };
}
return [
{
// Install the plugins without globs, so they can be configured separately.
- name: 'antfu/typescript/setup',
+ name: "antfu/typescript/setup",
plugins: {
antfu: pluginAntfu,
// "@typescript-eslint": pluginTs as any,
@@ -107,43 +107,43 @@ export async function typescript(
...isTypeAware ? tseslint.configs.strictTypeChecked : [],
{
files,
- name: 'antfu/typescript/rules',
+ name: "antfu/typescript/rules",
rules: {
- ...pluginTs.configs['eslint-recommended'].overrides![0].rules,
+ ...pluginTs.configs["eslint-recommended"].overrides![0].rules,
...pluginTs.configs.strict.rules,
- 'no-dupe-class-members': 'off',
- 'no-loss-of-precision': 'off',
- 'no-redeclare': 'off',
- 'no-use-before-define': 'off',
- 'no-useless-constructor': 'off',
- '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],
- '@typescript-eslint/ban-types': ['error', { types: { Function: false } }],
- '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
- '@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false, prefer: 'type-imports' }],
- '@typescript-eslint/method-signature-style': ['error', 'property'], // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
- '@typescript-eslint/no-dupe-class-members': 'error',
- '@typescript-eslint/no-dynamic-delete': 'off',
- '@typescript-eslint/no-explicit-any': 'off',
- '@typescript-eslint/no-extraneous-class': 'off',
- '@typescript-eslint/no-import-type-side-effects': 'error',
- '@typescript-eslint/no-invalid-void-type': 'off',
- '@typescript-eslint/no-loss-of-precision': 'error',
- '@typescript-eslint/no-non-null-assertion': 'off',
- '@typescript-eslint/no-redeclare': 'error',
- '@typescript-eslint/no-require-imports': 'error',
- '@typescript-eslint/no-unused-vars': 'off',
- '@typescript-eslint/no-use-before-define': ['error', { classes: false, functions: false, variables: true }],
- '@typescript-eslint/no-useless-constructor': 'off',
- '@typescript-eslint/prefer-ts-expect-error': 'error',
- '@typescript-eslint/triple-slash-reference': 'off',
- '@typescript-eslint/unified-signatures': 'off',
+ "no-dupe-class-members": "off",
+ "no-loss-of-precision": "off",
+ "no-redeclare": "off",
+ "no-use-before-define": "off",
+ "no-useless-constructor": "off",
+ "@typescript-eslint/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
+ "@typescript-eslint/ban-types": ["error", { types: { Function: false } }],
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
+ "@typescript-eslint/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
+ "@typescript-eslint/method-signature-style": ["error", "property"], // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
+ "@typescript-eslint/no-dupe-class-members": "error",
+ "@typescript-eslint/no-dynamic-delete": "off",
+ "@typescript-eslint/no-explicit-any": "off",
+ "@typescript-eslint/no-extraneous-class": "off",
+ "@typescript-eslint/no-import-type-side-effects": "error",
+ "@typescript-eslint/no-invalid-void-type": "off",
+ "@typescript-eslint/no-loss-of-precision": "error",
+ "@typescript-eslint/no-non-null-assertion": "off",
+ "@typescript-eslint/no-redeclare": "error",
+ "@typescript-eslint/no-require-imports": "error",
+ "@typescript-eslint/no-unused-vars": "off",
+ "@typescript-eslint/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
+ "@typescript-eslint/no-useless-constructor": "off",
+ "@typescript-eslint/prefer-ts-expect-error": "error",
+ "@typescript-eslint/triple-slash-reference": "off",
+ "@typescript-eslint/unified-signatures": "off",
...overrides,
},
},
...isTypeAware
? [{
files: filesTypeAware,
- name: 'antfu/typescript/rules-type-aware',
+ name: "antfu/typescript/rules-type-aware",
rules: {
...tsconfigPath ? typeAwareRules : {},
...overrides,
@@ -151,61 +151,61 @@ export async function typescript(
}]
: [],
{
- files: ['**/*.d.ts'],
- name: 'antfu/typescript/disables/dts',
+ files: ["**/*.d.ts"],
+ name: "antfu/typescript/disables/dts",
rules: {
- 'eslint-comments/no-unlimited-disable': 'off',
- 'import-x/no-duplicates': 'off',
- 'no-restricted-syntax': 'off',
- 'unused-imports/no-unused-vars': 'off',
+ "eslint-comments/no-unlimited-disable": "off",
+ "import-x/no-duplicates": "off",
+ "no-restricted-syntax": "off",
+ "unused-imports/no-unused-vars": "off",
},
},
{
- files: ['**/*.{test,spec}.ts?(x)'],
- name: 'antfu/typescript/disables/test',
+ files: ["**/*.{test,spec}.ts?(x)"],
+ name: "antfu/typescript/disables/test",
rules: {
- 'no-unused-expressions': 'off',
+ "no-unused-expressions": "off",
},
},
{
- files: ['**/*.js', '**/*.cjs'],
- name: 'antfu/typescript/disables/cjs',
+ files: ["**/*.js", "**/*.cjs"],
+ name: "antfu/typescript/disables/cjs",
rules: {
- '@typescript-eslint/no-require-imports': 'off',
- '@typescript-eslint/no-var-requires': 'off',
+ "@typescript-eslint/no-require-imports": "off",
+ "@typescript-eslint/no-var-requires": "off",
},
},
...compat.config({
- plugins: ['tsdoc'],
+ plugins: ["tsdoc"],
rules: {
- 'tsdoc/syntax': 'warn',
+ "tsdoc/syntax": "warn",
},
}),
isTypeAware
? {
- name: 'nirtamir2/typescript/expect-type',
+ name: "nirtamir2/typescript/expect-type",
...expectType,
files,
- ignores: ['.storybook/**'],
+ ignores: [".storybook/**"],
}
: null,
{
files,
- ignores: ['.storybook/**'],
+ ignores: [".storybook/**"],
rules: {
// #region @typescript-eslint off - too strict
- 'no-magic-numbers': 'off',
- '@typescript-eslint/no-magic-numbers': 'off',
- 'no-shadow': 'off',
- '@typescript-eslint/no-shadow': 'off',
- '@typescript-eslint/class-methods-use-this': 'off',
- '@typescript-eslint/consistent-type-definitions': 'off', // I think it's covered by etc/prefer-interface + I prefer interface than type
- '@typescript-eslint/explicit-module-boundary-types': 'off', // nice, but may need to off in tsx files? https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md#configuring-in-a-mixed-jsts-codebase
- '@typescript-eslint/explicit-function-return-type': 'off', // too strict
- '@typescript-eslint/prefer-readonly': 'off', // too strict to specify readonly on every param
- '@typescript-eslint/prefer-readonly-parameter-types': 'off', // too strict to specify readonly on every param
- '@typescript-eslint/naming-convention': [
- 'off',
+ "no-magic-numbers": "off",
+ "@typescript-eslint/no-magic-numbers": "off",
+ "no-shadow": "off",
+ "@typescript-eslint/no-shadow": "off",
+ "@typescript-eslint/class-methods-use-this": "off",
+ "@typescript-eslint/consistent-type-definitions": "off", // I think it's covered by etc/prefer-interface + I prefer interface than type
+ "@typescript-eslint/explicit-module-boundary-types": "off", // nice, but may need to off in tsx files? https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-module-boundary-types.md#configuring-in-a-mixed-jsts-codebase
+ "@typescript-eslint/explicit-function-return-type": "off", // too strict
+ "@typescript-eslint/prefer-readonly": "off", // too strict to specify readonly on every param
+ "@typescript-eslint/prefer-readonly-parameter-types": "off", // too strict to specify readonly on every param
+ "@typescript-eslint/naming-convention": [
+ "off",
/*
Too strict: sometimes we get stuff from server like user_id or call server with
.match({
@@ -248,249 +248,249 @@ export async function typescript(
*/
{
- selector: 'typeLike',
- format: ['PascalCase'],
+ selector: "typeLike",
+ format: ["PascalCase"],
},
// Mine:
{
- selector: 'interface',
- format: ['PascalCase'],
- prefix: ['I'],
+ selector: "interface",
+ format: ["PascalCase"],
+ prefix: ["I"],
},
{
- selector: 'typeLike',
- format: ['PascalCase'],
- suffix: ['T'],
+ selector: "typeLike",
+ format: ["PascalCase"],
+ suffix: ["T"],
},
],
// #endregion
// #region @typescript-eslint no need
- '@typescript-eslint/ban-tslint-comment': 'off',
+ "@typescript-eslint/ban-tslint-comment": "off",
// #endregion no need
// #region @typescript-eslint - warn
- 'no-unused-vars': 'off',
- '@typescript-eslint/no-unused-vars': [
- 'warn',
- { argsIgnorePattern: '^_' },
+ "no-unused-vars": "off",
+ "@typescript-eslint/no-unused-vars": [
+ "warn",
+ { argsIgnorePattern: "^_" },
],
// #endregion @typescript-eslint - too noisy rules
// #region @typescript-eslint - styling rules I don't care about (prettier can handle it so I put it in off)
- 'space-infix-ops': 'off',
- '@typescript-eslint/space-infix-ops': 'off',
- 'no-extra-parens': 'off',
- '@typescript-eslint/no-extra-parens': 'off',
- 'no-extra-semi': 'off',
- '@typescript-eslint/no-extra-semi': 'off',
- 'object-curly-spacing': 'off',
- '@typescript-eslint/object-curly-spacing': 'off',
- 'brace-style': 'off',
- '@typescript-eslint/brace-style': 'off',
- 'comma-dangle': 'off',
- '@typescript-eslint/comma-dangle': 'off',
- 'comma-spacing': 'off',
- '@typescript-eslint/comma-spacing': 'off',
- 'func-call-spacing': 'off',
- '@typescript-eslint/func-call-spacing': 'off',
- 'indent': 'off',
- '@typescript-eslint/indent': 'off',
- 'keyword-spacing': 'off',
- '@typescript-eslint/keyword-spacing': 'off',
- '@typescript-eslint/lines-between-class-members': 'off',
- '@typescript-eslint/member-delimiter-style': 'off',
- 'quotes': 'off',
- '@typescript-eslint/quotes': 'off',
- 'semi': 'off',
- '@typescript-eslint/semi': 'off',
- 'space-before-function-paren': 'off',
- '@typescript-eslint/space-before-function-paren': 'off',
- 'block-spacing': 'off',
- '@typescript-eslint/block-spacing': 'off',
- 'key-spacing': 'off',
- '@typescript-eslint/key-spacing': 'off',
- 'lines-around-comment': 'off',
- '@typescript-eslint/lines-around-comment': 'off',
- 'space-before-blocks': 'off',
- '@typescript-eslint/space-before-blocks': 'off',
+ "space-infix-ops": "off",
+ "@typescript-eslint/space-infix-ops": "off",
+ "no-extra-parens": "off",
+ "@typescript-eslint/no-extra-parens": "off",
+ "no-extra-semi": "off",
+ "@typescript-eslint/no-extra-semi": "off",
+ "object-curly-spacing": "off",
+ "@typescript-eslint/object-curly-spacing": "off",
+ "brace-style": "off",
+ "@typescript-eslint/brace-style": "off",
+ "comma-dangle": "off",
+ "@typescript-eslint/comma-dangle": "off",
+ "comma-spacing": "off",
+ "@typescript-eslint/comma-spacing": "off",
+ "func-call-spacing": "off",
+ "@typescript-eslint/func-call-spacing": "off",
+ "indent": "off",
+ "@typescript-eslint/indent": "off",
+ "keyword-spacing": "off",
+ "@typescript-eslint/keyword-spacing": "off",
+ "@typescript-eslint/lines-between-class-members": "off",
+ "@typescript-eslint/member-delimiter-style": "off",
+ "quotes": "off",
+ "@typescript-eslint/quotes": "off",
+ "semi": "off",
+ "@typescript-eslint/semi": "off",
+ "space-before-function-paren": "off",
+ "@typescript-eslint/space-before-function-paren": "off",
+ "block-spacing": "off",
+ "@typescript-eslint/block-spacing": "off",
+ "key-spacing": "off",
+ "@typescript-eslint/key-spacing": "off",
+ "lines-around-comment": "off",
+ "@typescript-eslint/lines-around-comment": "off",
+ "space-before-blocks": "off",
+ "@typescript-eslint/space-before-blocks": "off",
// #endregion
// #region @typescript-eslint all https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/configs/all.ts
- '@typescript-eslint/consistent-generic-constructors': 'error',
- '@typescript-eslint/no-unsafe-declaration-merging': 'error',
+ "@typescript-eslint/consistent-generic-constructors": "error",
+ "@typescript-eslint/no-unsafe-declaration-merging": "error",
// "@typescript-eslint/no-unsafe-enum-comparison": "error", new rule
- '@typescript-eslint/sort-type-constituents': 'off', // Style - too strict
- '@typescript-eslint/no-import-type-side-effects': 'error',
+ "@typescript-eslint/sort-type-constituents": "off", // Style - too strict
+ "@typescript-eslint/no-import-type-side-effects": "error",
- '@typescript-eslint/no-duplicate-enum-values': 'error',
- '@typescript-eslint/no-useless-empty-export': 'error',
- '@typescript-eslint/ban-ts-comment': [
- 'error',
+ "@typescript-eslint/no-duplicate-enum-values": "error",
+ "@typescript-eslint/no-useless-empty-export": "error",
+ "@typescript-eslint/ban-ts-comment": [
+ "error",
{
- 'ts-ignore': 'allow-with-description',
+ "ts-ignore": "allow-with-description",
},
],
- '@typescript-eslint/adjacent-overload-signatures': 'error',
- '@typescript-eslint/array-type': ['error', { default: 'generic' }],
- '@typescript-eslint/await-thenable': 'error',
- '@typescript-eslint/ban-types': [
- 'error',
+ "@typescript-eslint/adjacent-overload-signatures": "error",
+ "@typescript-eslint/array-type": ["error", { default: "generic" }],
+ "@typescript-eslint/await-thenable": "error",
+ "@typescript-eslint/ban-types": [
+ "error",
{
types: {
- 'String': {
- message: 'Use `string` instead.',
- fixWith: 'string',
+ "String": {
+ message: "Use `string` instead.",
+ fixWith: "string",
},
- 'Number': {
- message: 'Use `number` instead.',
- fixWith: 'number',
+ "Number": {
+ message: "Use `number` instead.",
+ fixWith: "number",
},
- 'Boolean': {
- message: 'Use `boolean` instead.',
- fixWith: 'boolean',
+ "Boolean": {
+ message: "Use `boolean` instead.",
+ fixWith: "boolean",
},
- 'Symbol': {
- message: 'Use `symbol` instead.',
- fixWith: 'symbol',
+ "Symbol": {
+ message: "Use `symbol` instead.",
+ fixWith: "symbol",
},
- 'Object': {
+ "Object": {
message:
- 'The `Object` type is mostly the same as `unknown`. You probably want `Record` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848',
- fixWith: 'Record',
+ "The `Object` type is mostly the same as `unknown`. You probably want `Record` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
+ fixWith: "Record",
},
- '{}': {
+ "{}": {
message:
- 'The `{}` type is mostly the same as `unknown`. You probably want `Record` instead.',
- fixWith: 'Record',
+ "The `{}` type is mostly the same as `unknown`. You probably want `Record` instead.",
+ fixWith: "Record",
},
- 'object': {
+ "object": {
message:
- 'The `object` type is hard to use. Use `Record` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848',
- fixWith: 'Record',
+ "The `object` type is hard to use. Use `Record` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
+ fixWith: "Record",
},
- 'Function':
- 'Use a specific function type instead, like `() => void`.',
+ "Function":
+ "Use a specific function type instead, like `() => void`.",
},
},
],
- '@typescript-eslint/class-literal-property-style': 'error', // IDK
- '@typescript-eslint/consistent-indexed-object-style': 'error',
- '@typescript-eslint/consistent-type-assertions': 'error',
- '@typescript-eslint/consistent-type-imports': 'error',
- '@typescript-eslint/consistent-type-exports': 'error',
- 'default-param-last': 'off',
- '@typescript-eslint/default-param-last': 'error',
- 'dot-notation': 'off',
- '@typescript-eslint/dot-notation': 'error',
- '@typescript-eslint/explicit-member-accessibility': 'error',
- 'init-declarations': 'off',
- '@typescript-eslint/init-declarations': 'error',
- 'lines-between-class-members': 'off',
- '@typescript-eslint/member-ordering': 'error',
- '@typescript-eslint/method-signature-style': 'error',
- 'no-array-constructor': 'off',
- '@typescript-eslint/no-array-constructor': 'error',
- '@typescript-eslint/no-base-to-string': 'error',
- '@typescript-eslint/no-confusing-non-null-assertion': 'error',
- '@typescript-eslint/no-confusing-void-expression': 'error',
- 'no-dupe-class-members': 'off',
- '@typescript-eslint/no-dupe-class-members': 'error',
- 'no-duplicate-imports': 'off',
- '@typescript-eslint/no-dynamic-delete': 'error',
- 'no-empty-function': 'off',
- '@typescript-eslint/no-empty-function': 'error',
- '@typescript-eslint/no-empty-interface': 'error',
- '@typescript-eslint/no-explicit-any': 'error',
- '@typescript-eslint/no-extra-non-null-assertion': 'error',
+ "@typescript-eslint/class-literal-property-style": "error", // IDK
+ "@typescript-eslint/consistent-indexed-object-style": "error",
+ "@typescript-eslint/consistent-type-assertions": "error",
+ "@typescript-eslint/consistent-type-imports": "error",
+ "@typescript-eslint/consistent-type-exports": "error",
+ "default-param-last": "off",
+ "@typescript-eslint/default-param-last": "error",
+ "dot-notation": "off",
+ "@typescript-eslint/dot-notation": "error",
+ "@typescript-eslint/explicit-member-accessibility": "error",
+ "init-declarations": "off",
+ "@typescript-eslint/init-declarations": "error",
+ "lines-between-class-members": "off",
+ "@typescript-eslint/member-ordering": "error",
+ "@typescript-eslint/method-signature-style": "error",
+ "no-array-constructor": "off",
+ "@typescript-eslint/no-array-constructor": "error",
+ "@typescript-eslint/no-base-to-string": "error",
+ "@typescript-eslint/no-confusing-non-null-assertion": "error",
+ "@typescript-eslint/no-confusing-void-expression": "error",
+ "no-dupe-class-members": "off",
+ "@typescript-eslint/no-dupe-class-members": "error",
+ "no-duplicate-imports": "off",
+ "@typescript-eslint/no-dynamic-delete": "error",
+ "no-empty-function": "off",
+ "@typescript-eslint/no-empty-function": "error",
+ "@typescript-eslint/no-empty-interface": "error",
+ "@typescript-eslint/no-explicit-any": "error",
+ "@typescript-eslint/no-extra-non-null-assertion": "error",
// Less important rules:
- '@typescript-eslint/no-extraneous-class': 'error',
- '@typescript-eslint/no-floating-promises': 'error',
- '@typescript-eslint/no-for-in-array': 'error',
- 'no-implied-eval': 'off',
- '@typescript-eslint/no-implied-eval': 'error',
- '@typescript-eslint/no-inferrable-types': 'error',
- 'no-invalid-this': 'off',
- '@typescript-eslint/no-invalid-this': 'error',
- '@typescript-eslint/no-invalid-void-type': 'error',
- 'no-loop-func': 'off',
- '@typescript-eslint/no-loop-func': 'error',
- 'no-loss-of-precision': 'off',
- '@typescript-eslint/no-loss-of-precision': 'error',
- '@typescript-eslint/no-meaningless-void-operator': 'error',
- '@typescript-eslint/no-misused-new': 'error',
- '@typescript-eslint/no-misused-promises': 'error',
- '@typescript-eslint/no-namespace': 'error',
- '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
- '@typescript-eslint/no-non-null-assertion': 'error',
- '@typescript-eslint/parameter-properties': 'error',
- 'no-redeclare': 'off',
- '@typescript-eslint/no-redeclare': 'error',
- '@typescript-eslint/no-require-imports': 'error',
- 'no-restricted-imports': 'off',
- '@typescript-eslint/no-restricted-imports': 'error',
- '@typescript-eslint/no-this-alias': 'error',
- 'no-throw-literal': 'off',
- '@typescript-eslint/no-throw-literal': 'error',
+ "@typescript-eslint/no-extraneous-class": "error",
+ "@typescript-eslint/no-floating-promises": "error",
+ "@typescript-eslint/no-for-in-array": "error",
+ "no-implied-eval": "off",
+ "@typescript-eslint/no-implied-eval": "error",
+ "@typescript-eslint/no-inferrable-types": "error",
+ "no-invalid-this": "off",
+ "@typescript-eslint/no-invalid-this": "error",
+ "@typescript-eslint/no-invalid-void-type": "error",
+ "no-loop-func": "off",
+ "@typescript-eslint/no-loop-func": "error",
+ "no-loss-of-precision": "off",
+ "@typescript-eslint/no-loss-of-precision": "error",
+ "@typescript-eslint/no-meaningless-void-operator": "error",
+ "@typescript-eslint/no-misused-new": "error",
+ "@typescript-eslint/no-misused-promises": "error",
+ "@typescript-eslint/no-namespace": "error",
+ "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
+ "@typescript-eslint/no-non-null-assertion": "error",
+ "@typescript-eslint/parameter-properties": "error",
+ "no-redeclare": "off",
+ "@typescript-eslint/no-redeclare": "error",
+ "@typescript-eslint/no-require-imports": "error",
+ "no-restricted-imports": "off",
+ "@typescript-eslint/no-restricted-imports": "error",
+ "@typescript-eslint/no-this-alias": "error",
+ "no-throw-literal": "off",
+ "@typescript-eslint/no-throw-literal": "error",
// "@typescript-eslint/no-type-alias": "off", // A & B, type AppRouter = typeof appRouter, Merge
- '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
- '@typescript-eslint/no-unnecessary-condition': 'error',
- '@typescript-eslint/no-unnecessary-qualifier': 'error',
- '@typescript-eslint/no-unnecessary-type-arguments': 'error',
- '@typescript-eslint/no-unnecessary-type-assertion': 'error',
- '@typescript-eslint/no-unnecessary-type-constraint': 'error',
- '@typescript-eslint/no-unsafe-argument': 'error',
- '@typescript-eslint/no-unsafe-assignment': 'error',
- '@typescript-eslint/no-unsafe-call': 'error',
- '@typescript-eslint/no-unsafe-member-access': 'error',
- '@typescript-eslint/no-unsafe-return': 'error',
- 'no-unused-expressions': 'off',
- '@typescript-eslint/no-unused-expressions': 'error',
- 'no-use-before-define': 'off',
- '@typescript-eslint/no-use-before-define': 'error',
- 'no-useless-constructor': 'off',
- '@typescript-eslint/no-useless-constructor': 'error',
- '@typescript-eslint/no-var-requires': 'error',
- '@typescript-eslint/non-nullable-type-assertion-style': 'error',
- 'padding-line-between-statements': 'off',
- '@typescript-eslint/padding-line-between-statements': 'error',
- '@typescript-eslint/prefer-as-const': 'error',
- '@typescript-eslint/prefer-enum-initializers': 'error',
- '@typescript-eslint/prefer-for-of': 'error',
- '@typescript-eslint/prefer-function-type': 'error',
- '@typescript-eslint/prefer-includes': 'error',
- '@typescript-eslint/prefer-literal-enum-member': 'error',
- '@typescript-eslint/prefer-namespace-keyword': 'error',
- '@typescript-eslint/prefer-nullish-coalescing': 'error',
- '@typescript-eslint/prefer-optional-chain': 'error',
- '@typescript-eslint/prefer-reduce-type-parameter': 'error',
- '@typescript-eslint/prefer-regexp-exec': 'error',
- '@typescript-eslint/prefer-return-this-type': 'error',
- '@typescript-eslint/prefer-string-starts-ends-with': 'error',
- '@typescript-eslint/prefer-ts-expect-error': 'error',
- '@typescript-eslint/promise-function-async': 'error',
- '@typescript-eslint/require-array-sort-compare': 'error',
- 'require-await': 'off',
- '@typescript-eslint/require-await': 'error',
- '@typescript-eslint/restrict-plus-operands': 'error',
- '@typescript-eslint/restrict-template-expressions': 'error',
- 'no-return-await': 'off',
- '@typescript-eslint/return-await': ['error', 'always'],
- '@typescript-eslint/strict-boolean-expressions': 'error',
- '@typescript-eslint/switch-exhaustiveness-check': 'error',
- '@typescript-eslint/triple-slash-reference': 'error',
- '@typescript-eslint/type-annotation-spacing': 'error',
- '@typescript-eslint/typedef': 'error',
- '@typescript-eslint/unbound-method': 'error',
- '@typescript-eslint/unified-signatures': 'error',
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
+ "@typescript-eslint/no-unnecessary-condition": "error",
+ "@typescript-eslint/no-unnecessary-qualifier": "error",
+ "@typescript-eslint/no-unnecessary-type-arguments": "error",
+ "@typescript-eslint/no-unnecessary-type-assertion": "error",
+ "@typescript-eslint/no-unnecessary-type-constraint": "error",
+ "@typescript-eslint/no-unsafe-argument": "error",
+ "@typescript-eslint/no-unsafe-assignment": "error",
+ "@typescript-eslint/no-unsafe-call": "error",
+ "@typescript-eslint/no-unsafe-member-access": "error",
+ "@typescript-eslint/no-unsafe-return": "error",
+ "no-unused-expressions": "off",
+ "@typescript-eslint/no-unused-expressions": "error",
+ "no-use-before-define": "off",
+ "@typescript-eslint/no-use-before-define": "error",
+ "no-useless-constructor": "off",
+ "@typescript-eslint/no-useless-constructor": "error",
+ "@typescript-eslint/no-var-requires": "error",
+ "@typescript-eslint/non-nullable-type-assertion-style": "error",
+ "padding-line-between-statements": "off",
+ "@typescript-eslint/padding-line-between-statements": "error",
+ "@typescript-eslint/prefer-as-const": "error",
+ "@typescript-eslint/prefer-enum-initializers": "error",
+ "@typescript-eslint/prefer-for-of": "error",
+ "@typescript-eslint/prefer-function-type": "error",
+ "@typescript-eslint/prefer-includes": "error",
+ "@typescript-eslint/prefer-literal-enum-member": "error",
+ "@typescript-eslint/prefer-namespace-keyword": "error",
+ "@typescript-eslint/prefer-nullish-coalescing": "error",
+ "@typescript-eslint/prefer-optional-chain": "error",
+ "@typescript-eslint/prefer-reduce-type-parameter": "error",
+ "@typescript-eslint/prefer-regexp-exec": "error",
+ "@typescript-eslint/prefer-return-this-type": "error",
+ "@typescript-eslint/prefer-string-starts-ends-with": "error",
+ "@typescript-eslint/prefer-ts-expect-error": "error",
+ "@typescript-eslint/promise-function-async": "error",
+ "@typescript-eslint/require-array-sort-compare": "error",
+ "require-await": "off",
+ "@typescript-eslint/require-await": "error",
+ "@typescript-eslint/restrict-plus-operands": "error",
+ "@typescript-eslint/restrict-template-expressions": "error",
+ "no-return-await": "off",
+ "@typescript-eslint/return-await": ["error", "always"],
+ "@typescript-eslint/strict-boolean-expressions": "error",
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
+ "@typescript-eslint/triple-slash-reference": "error",
+ "@typescript-eslint/type-annotation-spacing": "error",
+ "@typescript-eslint/typedef": "error",
+ "@typescript-eslint/unbound-method": "error",
+ "@typescript-eslint/unified-signatures": "error",
// #endregion
- 'array-callback-return': 'off', // https://github.com/typescript-eslint/typescript-eslint/issues/2841 - false positive with TypeScript
+ "array-callback-return": "off", // https://github.com/typescript-eslint/typescript-eslint/issues/2841 - false positive with TypeScript
},
},
isTypeAware ? null : tseslint.configs.disableTypeChecked,
- ]
+ ];
}
diff --git a/src/configs/unicorn.ts b/src/configs/unicorn.ts
index 682e0e607d..1ab9d24b2b 100644
--- a/src/configs/unicorn.ts
+++ b/src/configs/unicorn.ts
@@ -1,62 +1,62 @@
-import type { TypedFlatConfigItem } from '../types'
-import { pluginUnicorn } from '../plugins'
+import type { TypedFlatConfigItem } from "../types";
+import { pluginUnicorn } from "../plugins";
export async function unicorn(): Promise> {
return [
{
- name: 'nirtamir2/unicorn/rules',
+ name: "nirtamir2/unicorn/rules",
rules: {
- ...pluginUnicorn.configs['flat/recommended'].rules,
+ ...pluginUnicorn.configs["flat/recommended"].rules,
// #region unicorn
- 'unicorn/consistent-destructuring': 'warn',
- 'unicorn/filename-case': 0,
+ "unicorn/consistent-destructuring": "warn",
+ "unicorn/filename-case": 0,
/**
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/9c3f180c3ce35b3e488c076a243bf5b935c108ef/docs/rules/no-null.md
* I use null to check for null / undefined with `variableName == null`
*/
- 'unicorn/no-null': 0,
- 'unicorn/numeric-separators-style': 0,
+ "unicorn/no-null": 0,
+ "unicorn/numeric-separators-style": 0,
/**
* @see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/9c3f180c3ce35b3e488c076a243bf5b935c108ef/docs/rules/prevent-abbreviations.md
* I prefer variables with short scope to be called with short name like e instead of event
*/
- 'unicorn/prevent-abbreviations': 0,
+ "unicorn/prevent-abbreviations": 0,
// #endregion unicorn
},
},
{
- name: 'antfu/unicorn/rules',
+ name: "antfu/unicorn/rules",
plugins: {
unicorn: pluginUnicorn,
},
rules: {
// Pass error message when throwing errors
- 'unicorn/error-message': 'error',
+ "unicorn/error-message": "error",
// Uppercase regex escapes
- 'unicorn/escape-case': 'error',
+ "unicorn/escape-case": "error",
// Array.isArray instead of instanceof
- 'unicorn/no-instanceof-array': 'error',
+ "unicorn/no-instanceof-array": "error",
// Ban `new Array` as `Array` constructor's params are ambiguous
- 'unicorn/no-new-array': 'error',
+ "unicorn/no-new-array": "error",
// Prevent deprecated `new Buffer()`
- 'unicorn/no-new-buffer': 'error',
+ "unicorn/no-new-buffer": "error",
// Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
- 'unicorn/number-literal-case': 'error',
+ "unicorn/number-literal-case": "error",
// textContent instead of innerText
- 'unicorn/prefer-dom-node-text-content': 'error',
+ "unicorn/prefer-dom-node-text-content": "error",
// includes over indexOf when checking for existence
- 'unicorn/prefer-includes': 'error',
+ "unicorn/prefer-includes": "error",
// Prefer using the node: protocol
- 'unicorn/prefer-node-protocol': 'error',
+ "unicorn/prefer-node-protocol": "error",
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
- 'unicorn/prefer-number-properties': 'error',
+ "unicorn/prefer-number-properties": "error",
// String methods startsWith/endsWith instead of more complicated stuff
- 'unicorn/prefer-string-starts-ends-with': 'error',
+ "unicorn/prefer-string-starts-ends-with": "error",
// Enforce throwing type error when throwing error while checking typeof
- 'unicorn/prefer-type-error': 'error',
+ "unicorn/prefer-type-error": "error",
// Use new when throwing error
- 'unicorn/throw-new-error': 'error',
+ "unicorn/throw-new-error": "error",
},
},
- ]
+ ];
}
diff --git a/src/configs/unocss.ts b/src/configs/unocss.ts
index 5ce49b6869..70a145088b 100644
--- a/src/configs/unocss.ts
+++ b/src/configs/unocss.ts
@@ -1,5 +1,5 @@
-import { ensurePackages, interopDefault } from '../utils'
-import type { OptionsUnoCSS, TypedFlatConfigItem } from '../types'
+import { ensurePackages, interopDefault } from "../utils";
+import type { OptionsUnoCSS, TypedFlatConfigItem } from "../types";
export async function unocss(
options: OptionsUnoCSS = {},
@@ -7,37 +7,37 @@ export async function unocss(
const {
attributify = true,
strict = false,
- } = options
+ } = options;
await ensurePackages([
- '@unocss/eslint-plugin',
- ])
+ "@unocss/eslint-plugin",
+ ]);
const [
pluginUnoCSS,
] = await Promise.all([
- interopDefault(import('@unocss/eslint-plugin')),
- ] as const)
+ interopDefault(import("@unocss/eslint-plugin")),
+ ] as const);
return [
{
- name: 'antfu/unocss',
+ name: "antfu/unocss",
plugins: {
unocss: pluginUnoCSS,
},
rules: {
- 'unocss/order': 'warn',
+ "unocss/order": "warn",
...attributify
? {
- 'unocss/order-attributify': 'warn',
+ "unocss/order-attributify": "warn",
}
: {},
...strict
? {
- 'unocss/blocklist': 'error',
+ "unocss/blocklist": "error",
}
: {},
},
},
- ]
+ ];
}
diff --git a/src/configs/vue.ts b/src/configs/vue.ts
index b48e1dda71..e6921934ad 100644
--- a/src/configs/vue.ts
+++ b/src/configs/vue.ts
@@ -1,7 +1,7 @@
-import { mergeProcessors } from 'eslint-merge-processors'
-import { interopDefault } from '../utils'
-import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, OptionsVue, TypedFlatConfigItem } from '../types'
-import { GLOB_VUE } from '../globs'
+import { mergeProcessors } from "eslint-merge-processors";
+import { interopDefault } from "../utils";
+import type { OptionsFiles, OptionsHasTypeScript, OptionsOverrides, OptionsStylistic, OptionsVue, TypedFlatConfigItem } from "../types";
+import { GLOB_VUE } from "../globs";
export async function vue(
options: OptionsVue & OptionsHasTypeScript & OptionsOverrides & OptionsStylistic & OptionsFiles = {},
@@ -11,15 +11,15 @@ export async function vue(
overrides = {},
stylistic = true,
vueVersion = 3,
- } = options
+ } = options;
const sfcBlocks = options.sfcBlocks === true
? {}
- : options.sfcBlocks ?? {}
+ : options.sfcBlocks ?? {};
const {
indent = 2,
- } = typeof stylistic === 'boolean' ? {} : stylistic
+ } = typeof stylistic === "boolean" ? {} : stylistic;
const [
pluginVue,
@@ -27,10 +27,10 @@ export async function vue(
processorVueBlocks,
] = await Promise.all([
// @ts-expect-error missing types
- interopDefault(import('eslint-plugin-vue')),
- interopDefault(import('vue-eslint-parser')),
- interopDefault(import('eslint-processor-vue-blocks')),
- ] as const)
+ interopDefault(import("eslint-plugin-vue")),
+ interopDefault(import("vue-eslint-parser")),
+ interopDefault(import("eslint-processor-vue-blocks")),
+ ] as const);
return [
{
@@ -38,23 +38,23 @@ export async function vue(
// https://github.com/vuejs/eslint-plugin-vue/pull/2422
languageOptions: {
globals: {
- computed: 'readonly',
- defineEmits: 'readonly',
- defineExpose: 'readonly',
- defineProps: 'readonly',
- onMounted: 'readonly',
- onUnmounted: 'readonly',
- reactive: 'readonly',
- ref: 'readonly',
- shallowReactive: 'readonly',
- shallowRef: 'readonly',
- toRef: 'readonly',
- toRefs: 'readonly',
- watch: 'readonly',
- watchEffect: 'readonly',
+ computed: "readonly",
+ defineEmits: "readonly",
+ defineExpose: "readonly",
+ defineProps: "readonly",
+ onMounted: "readonly",
+ onUnmounted: "readonly",
+ reactive: "readonly",
+ ref: "readonly",
+ shallowReactive: "readonly",
+ shallowRef: "readonly",
+ toRef: "readonly",
+ toRefs: "readonly",
+ watch: "readonly",
+ watchEffect: "readonly",
},
},
- name: 'antfu/vue/setup',
+ name: "antfu/vue/setup",
plugins: {
vue: pluginVue,
},
@@ -67,18 +67,18 @@ export async function vue(
ecmaFeatures: {
jsx: true,
},
- extraFileExtensions: ['.vue'],
+ extraFileExtensions: [".vue"],
parser: options.typescript
- ? await interopDefault(import('@typescript-eslint/parser')) as any
+ ? await interopDefault(import("@typescript-eslint/parser")) as any
: null,
- sourceType: 'module',
+ sourceType: "module",
},
},
- name: 'antfu/vue/rules',
+ name: "antfu/vue/rules",
processor: sfcBlocks === false
- ? pluginVue.processors['.vue']
+ ? pluginVue.processors[".vue"]
: mergeProcessors([
- pluginVue.processors['.vue'],
+ pluginVue.processors[".vue"],
processorVueBlocks({
...sfcBlocks,
blocks: {
@@ -93,98 +93,98 @@ export async function vue(
...vueVersion === 2
? {
...pluginVue.configs.essential.rules as any,
- ...pluginVue.configs['strongly-recommended'].rules as any,
+ ...pluginVue.configs["strongly-recommended"].rules as any,
...pluginVue.configs.recommended.rules as any,
}
: {
- ...pluginVue.configs['vue3-essential'].rules as any,
- ...pluginVue.configs['vue3-strongly-recommended'].rules as any,
- ...pluginVue.configs['vue3-recommended'].rules as any,
+ ...pluginVue.configs["vue3-essential"].rules as any,
+ ...pluginVue.configs["vue3-strongly-recommended"].rules as any,
+ ...pluginVue.configs["vue3-recommended"].rules as any,
},
- 'n/prefer-global/process': 'off',
- 'vue/block-order': ['error', {
- order: ['script', 'template', 'style'],
+ "n/prefer-global/process": "off",
+ "vue/block-order": ["error", {
+ order: ["script", "template", "style"],
}],
- 'vue/component-name-in-template-casing': ['error', 'PascalCase'],
- 'vue/component-options-name-casing': ['error', 'PascalCase'],
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
+ "vue/component-options-name-casing": ["error", "PascalCase"],
// this is deprecated
- 'vue/component-tags-order': 'off',
- 'vue/custom-event-name-casing': ['error', 'camelCase'],
- 'vue/define-macros-order': ['error', {
- order: ['defineOptions', 'defineProps', 'defineEmits', 'defineSlots'],
+ "vue/component-tags-order": "off",
+ "vue/custom-event-name-casing": ["error", "camelCase"],
+ "vue/define-macros-order": ["error", {
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"],
}],
- 'vue/dot-location': ['error', 'property'],
- 'vue/dot-notation': ['error', { allowKeywords: true }],
- 'vue/eqeqeq': ['error', 'smart'],
- 'vue/html-indent': ['error', indent],
- 'vue/html-quotes': ['error', 'double'],
- 'vue/max-attributes-per-line': 'off',
- 'vue/multi-word-component-names': 'off',
- 'vue/no-dupe-keys': 'off',
- 'vue/no-empty-pattern': 'error',
- 'vue/no-irregular-whitespace': 'error',
- 'vue/no-loss-of-precision': 'error',
- 'vue/no-restricted-syntax': [
- 'error',
- 'DebuggerStatement',
- 'LabeledStatement',
- 'WithStatement',
+ "vue/dot-location": ["error", "property"],
+ "vue/dot-notation": ["error", { allowKeywords: true }],
+ "vue/eqeqeq": ["error", "smart"],
+ "vue/html-indent": ["error", indent],
+ "vue/html-quotes": ["error", "double"],
+ "vue/max-attributes-per-line": "off",
+ "vue/multi-word-component-names": "off",
+ "vue/no-dupe-keys": "off",
+ "vue/no-empty-pattern": "error",
+ "vue/no-irregular-whitespace": "error",
+ "vue/no-loss-of-precision": "error",
+ "vue/no-restricted-syntax": [
+ "error",
+ "DebuggerStatement",
+ "LabeledStatement",
+ "WithStatement",
],
- 'vue/no-restricted-v-bind': ['error', '/^v-/'],
- 'vue/no-setup-props-reactivity-loss': 'off',
- 'vue/no-sparse-arrays': 'error',
- 'vue/no-unused-refs': 'error',
- 'vue/no-useless-v-bind': 'error',
- 'vue/no-v-html': 'off',
- 'vue/object-shorthand': [
- 'error',
- 'always',
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
+ "vue/no-setup-props-reactivity-loss": "off",
+ "vue/no-sparse-arrays": "error",
+ "vue/no-unused-refs": "error",
+ "vue/no-useless-v-bind": "error",
+ "vue/no-v-html": "off",
+ "vue/object-shorthand": [
+ "error",
+ "always",
{
avoidQuotes: true,
ignoreConstructors: false,
},
],
- 'vue/prefer-separate-static-class': 'error',
- 'vue/prefer-template': 'error',
- 'vue/prop-name-casing': ['error', 'camelCase'],
- 'vue/require-default-prop': 'off',
- 'vue/require-prop-types': 'off',
- 'vue/space-infix-ops': 'error',
- 'vue/space-unary-ops': ['error', { nonwords: false, words: true }],
+ "vue/prefer-separate-static-class": "error",
+ "vue/prefer-template": "error",
+ "vue/prop-name-casing": ["error", "camelCase"],
+ "vue/require-default-prop": "off",
+ "vue/require-prop-types": "off",
+ "vue/space-infix-ops": "error",
+ "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
...stylistic
? {
- 'vue/array-bracket-spacing': ['error', 'never'],
- 'vue/arrow-spacing': ['error', { after: true, before: true }],
- 'vue/block-spacing': ['error', 'always'],
- 'vue/block-tag-newline': ['error', {
- multiline: 'always',
- singleline: 'always',
+ "vue/array-bracket-spacing": ["error", "never"],
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
+ "vue/block-spacing": ["error", "always"],
+ "vue/block-tag-newline": ["error", {
+ multiline: "always",
+ singleline: "always",
}],
- 'vue/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
- 'vue/comma-dangle': ['error', 'always-multiline'],
- 'vue/comma-spacing': ['error', { after: true, before: false }],
- 'vue/comma-style': ['error', 'last'],
- 'vue/html-comment-content-spacing': ['error', 'always', {
- exceptions: ['-'],
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
+ "vue/comma-dangle": ["error", "always-multiline"],
+ "vue/comma-spacing": ["error", { after: true, before: false }],
+ "vue/comma-style": ["error", "last"],
+ "vue/html-comment-content-spacing": ["error", "always", {
+ exceptions: ["-"],
}],
- 'vue/key-spacing': ['error', { afterColon: true, beforeColon: false }],
- 'vue/keyword-spacing': ['error', { after: true, before: true }],
- 'vue/object-curly-newline': 'off',
- 'vue/object-curly-spacing': ['error', 'always'],
- 'vue/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
- 'vue/operator-linebreak': ['error', 'before'],
- 'vue/padding-line-between-blocks': ['error', 'always'],
- 'vue/quote-props': ['error', 'consistent-as-needed'],
- 'vue/space-in-parens': ['error', 'never'],
- 'vue/template-curly-spacing': 'error',
+ "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
+ "vue/object-curly-newline": "off",
+ "vue/object-curly-spacing": ["error", "always"],
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
+ "vue/operator-linebreak": ["error", "before"],
+ "vue/padding-line-between-blocks": ["error", "always"],
+ "vue/quote-props": ["error", "consistent-as-needed"],
+ "vue/space-in-parens": ["error", "never"],
+ "vue/template-curly-spacing": "error",
}
: {},
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/configs/yaml.ts b/src/configs/yaml.ts
index 1575dfc60a..877b416610 100644
--- a/src/configs/yaml.ts
+++ b/src/configs/yaml.ts
@@ -1,6 +1,6 @@
-import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from '../types'
-import { GLOB_YAML } from '../globs'
-import { interopDefault } from '../utils'
+import type { OptionsFiles, OptionsOverrides, OptionsStylistic, TypedFlatConfigItem } from "../types";
+import { GLOB_YAML } from "../globs";
+import { interopDefault } from "../utils";
export async function yaml(
options: OptionsOverrides & OptionsStylistic & OptionsFiles = {},
@@ -9,24 +9,24 @@ export async function yaml(
files = [GLOB_YAML],
overrides = {},
stylistic = true,
- } = options
+ } = options;
const {
indent = 2,
- quotes = 'single',
- } = typeof stylistic === 'boolean' ? {} : stylistic
+ quotes = "single",
+ } = typeof stylistic === "boolean" ? {} : stylistic;
const [
pluginYaml,
parserYaml,
] = await Promise.all([
- interopDefault(import('eslint-plugin-yml')),
- interopDefault(import('yaml-eslint-parser')),
- ] as const)
+ interopDefault(import("eslint-plugin-yml")),
+ interopDefault(import("yaml-eslint-parser")),
+ ] as const);
return [
{
- name: 'antfu/yml/setup',
+ name: "antfu/yml/setup",
plugins: {
yml: pluginYaml,
},
@@ -36,37 +36,37 @@ export async function yaml(
languageOptions: {
parser: parserYaml,
},
- name: 'antfu/yaml/rules',
+ name: "antfu/yaml/rules",
rules: {
- '@stylistic/spaced-comment': 'off',
+ "@stylistic/spaced-comment": "off",
- 'yml/block-mapping': 'error',
- 'yml/block-sequence': 'error',
- 'yml/no-empty-key': 'error',
- 'yml/no-empty-sequence-entry': 'error',
- 'yml/no-irregular-whitespace': 'error',
- 'yml/plain-scalar': 'error',
+ "yml/block-mapping": "error",
+ "yml/block-sequence": "error",
+ "yml/no-empty-key": "error",
+ "yml/no-empty-sequence-entry": "error",
+ "yml/no-irregular-whitespace": "error",
+ "yml/plain-scalar": "error",
- 'yml/vue-custom-block/no-parsing-error': 'error',
+ "yml/vue-custom-block/no-parsing-error": "error",
...stylistic
? {
- 'yml/block-mapping-question-indicator-newline': 'error',
- 'yml/block-sequence-hyphen-indicator-newline': 'error',
- 'yml/flow-mapping-curly-newline': 'error',
- 'yml/flow-mapping-curly-spacing': 'error',
- 'yml/flow-sequence-bracket-newline': 'error',
- 'yml/flow-sequence-bracket-spacing': 'error',
- 'yml/indent': ['error', indent === 'tab' ? 2 : indent],
- 'yml/key-spacing': 'error',
- 'yml/no-tab-indent': 'error',
- 'yml/quotes': ['error', { avoidEscape: false, prefer: quotes }],
- 'yml/spaced-comment': 'error',
+ "yml/block-mapping-question-indicator-newline": "error",
+ "yml/block-sequence-hyphen-indicator-newline": "error",
+ "yml/flow-mapping-curly-newline": "error",
+ "yml/flow-mapping-curly-spacing": "error",
+ "yml/flow-sequence-bracket-newline": "error",
+ "yml/flow-sequence-bracket-spacing": "error",
+ "yml/indent": ["error", indent === "tab" ? 2 : indent],
+ "yml/key-spacing": "error",
+ "yml/no-tab-indent": "error",
+ "yml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
+ "yml/spaced-comment": "error",
}
: {},
...overrides,
},
},
- ]
+ ];
}
diff --git a/src/factory.ts b/src/factory.ts
index 31e8d25f81..77cf273dfc 100644
--- a/src/factory.ts
+++ b/src/factory.ts
@@ -1,9 +1,9 @@
-import process from 'node:process'
-import fs from 'node:fs'
-import { isPackageExists } from 'local-pkg'
-import { FlatConfigComposer } from 'eslint-flat-config-utils'
-import type { Linter } from 'eslint'
-import type { Awaitable, ConfigNames, OptionsConfig, TypedFlatConfigItem } from './types'
+import process from "node:process";
+import fs from "node:fs";
+import { isPackageExists } from "local-pkg";
+import { FlatConfigComposer } from "eslint-flat-config-utils";
+import type { Linter } from "eslint";
+import type { Awaitable, ConfigNames, OptionsConfig, TypedFlatConfigItem } from "./types";
import {
astro,
command,
@@ -29,59 +29,59 @@ import {
unocss,
vue,
yaml,
-} from './configs'
-import { interopDefault } from './utils'
-import { formatters } from './configs/formatters'
-import { regexp } from './configs/regexp'
-import { prettier } from './configs/prettier'
-import { tailwindcss } from './configs/tailwindcss'
-import { storybook } from './configs/storybook'
-import { i18n } from './configs/i18n'
-import { security } from './configs/security'
+} from "./configs";
+import { interopDefault } from "./utils";
+import { formatters } from "./configs/formatters";
+import { regexp } from "./configs/regexp";
+import { prettier } from "./configs/prettier";
+import { tailwindcss } from "./configs/tailwindcss";
+import { storybook } from "./configs/storybook";
+import { i18n } from "./configs/i18n";
+import { security } from "./configs/security";
const flatConfigProps: Array = [
- 'name',
- 'files',
- 'ignores',
- 'languageOptions',
- 'linterOptions',
- 'processor',
- 'plugins',
- 'rules',
- 'settings',
-]
+ "name",
+ "files",
+ "ignores",
+ "languageOptions",
+ "linterOptions",
+ "processor",
+ "plugins",
+ "rules",
+ "settings",
+];
const VuePackages = [
- 'vue',
- 'nuxt',
- 'vitepress',
- '@slidev/cli',
-]
+ "vue",
+ "nuxt",
+ "vitepress",
+ "@slidev/cli",
+];
const StorybookPackages = [
- '@storybook/addon-a11y',
- '@storybook/addon-essentials',
- '@storybook/addon-interactions',
- '@storybook/addon-links',
- '@storybook/addon-storysource',
- '@storybook/blocks',
- '@storybook/nextjs',
- '@storybook/react',
- '@storybook/test',
-]
+ "@storybook/addon-a11y",
+ "@storybook/addon-essentials",
+ "@storybook/addon-interactions",
+ "@storybook/addon-links",
+ "@storybook/addon-storysource",
+ "@storybook/blocks",
+ "@storybook/nextjs",
+ "@storybook/react",
+ "@storybook/test",
+];
export const defaultPluginRenaming = {
- '@eslint-react': 'react',
- '@eslint-react/dom': 'react-dom',
- '@eslint-react/hooks-extra': 'react-hooks-extra',
- '@eslint-react/naming-convention': 'react-naming-convention',
-
- '@stylistic': 'style',
- '@typescript-eslint': 'ts',
- 'import-x': 'import',
- 'n': 'node',
- 'vitest': 'test',
- 'yml': 'yaml',
-}
+ "@eslint-react": "react",
+ "@eslint-react/dom": "react-dom",
+ "@eslint-react/hooks-extra": "react-hooks-extra",
+ "@eslint-react/naming-convention": "react-naming-convention",
+
+ "@stylistic": "style",
+ "@typescript-eslint": "ts",
+ "import-x": "import",
+ "n": "node",
+ "vitest": "test",
+ "yml": "yaml",
+};
/**
* Construct an array of ESLint flat config items.
@@ -106,45 +106,45 @@ export function antfu(
regexp: enableRegexp = true,
solid: enableSolid = false,
svelte: enableSvelte = false,
- tailwindcss: enableTailwindCSS = isPackageExists('tailwindcss'),
- typescript: enableTypeScript = isPackageExists('typescript'),
+ tailwindcss: enableTailwindCSS = isPackageExists("tailwindcss"),
+ typescript: enableTypeScript = isPackageExists("typescript"),
unocss: enableUnoCSS = false,
vue: enableVue = VuePackages.some(i => isPackageExists(i)),
storybook: enableStorybook = StorybookPackages.some(i => isPackageExists(i)),
i18n: enableI18n = false,
security: enableSecurity = false,
- } = options
+ } = options;
const stylisticOptions = options.stylistic === false
? false
- : typeof options.stylistic === 'object'
+ : typeof options.stylistic === "object"
? options.stylistic
- : {}
+ : {};
- if (stylisticOptions && !('jsx' in stylisticOptions))
- stylisticOptions.jsx = options.jsx ?? true
+ if (stylisticOptions && !("jsx" in stylisticOptions))
+ stylisticOptions.jsx = options.jsx ?? true;
- const configs: Array>> = []
+ const configs: Array>> = [];
if (enableGitignore) {
- if (typeof enableGitignore === 'boolean') {
- if (fs.existsSync('.gitignore'))
- configs.push(interopDefault(import('eslint-config-flat-gitignore')).then(r => [r()]))
+ if (typeof enableGitignore === "boolean") {
+ if (fs.existsSync(".gitignore"))
+ configs.push(interopDefault(import("eslint-config-flat-gitignore")).then(r => [r()]));
}
else {
- configs.push(interopDefault(import('eslint-config-flat-gitignore')).then(r => [r(enableGitignore)]))
+ configs.push(interopDefault(import("eslint-config-flat-gitignore")).then(r => [r(enableGitignore)]));
}
}
- const typescriptOptions = resolveSubOptions(options, 'typescript')
- const tsconfigPath = 'tsconfigPath' in typescriptOptions ? typescriptOptions.tsconfigPath : undefined
+ const typescriptOptions = resolveSubOptions(options, "typescript");
+ const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : undefined;
// Base configs
configs.push(
ignores(),
javascript({
isInEditor,
- overrides: getOverrides(options, 'javascript'),
+ overrides: getOverrides(options, "javascript"),
}),
comments(),
node(),
@@ -159,124 +159,124 @@ export function antfu(
// Optional plugins (installed but not enabled by default)
perfectionist(),
- )
+ );
if (enableVue) {
- componentExts.push('vue')
+ componentExts.push("vue");
}
if (enableTypeScript) {
configs.push(typescript({
...typescriptOptions,
componentExts,
- overrides: getOverrides(options, 'typescript'),
- }))
+ overrides: getOverrides(options, "typescript"),
+ }));
}
if (stylisticOptions) {
configs.push(stylistic({
...stylisticOptions,
lessOpinionated: options.lessOpinionated,
- overrides: getOverrides(options, 'stylistic'),
- }))
+ overrides: getOverrides(options, "stylistic"),
+ }));
}
if (enableRegexp) {
- configs.push(regexp(typeof enableRegexp === 'boolean' ? {} : enableRegexp))
+ configs.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
}
if (options.test ?? true) {
configs.push(test({
isInEditor,
- overrides: getOverrides(options, 'test'),
- }))
+ overrides: getOverrides(options, "test"),
+ }));
}
if (enableVue) {
configs.push(vue({
- ...resolveSubOptions(options, 'vue'),
- overrides: getOverrides(options, 'vue'),
+ ...resolveSubOptions(options, "vue"),
+ overrides: getOverrides(options, "vue"),
stylistic: stylisticOptions,
typescript: Boolean(enableTypeScript),
- }))
+ }));
}
if (enableReact) {
configs.push(react({
- overrides: getOverrides(options, 'react'),
+ overrides: getOverrides(options, "react"),
tsconfigPath,
- }))
+ }));
}
if (enableSolid) {
configs.push(solid({
- overrides: getOverrides(options, 'solid'),
+ overrides: getOverrides(options, "solid"),
tsconfigPath,
typescript: Boolean(enableTypeScript),
- }))
+ }));
}
if (enableSvelte) {
configs.push(svelte({
- overrides: getOverrides(options, 'svelte'),
+ overrides: getOverrides(options, "svelte"),
stylistic: stylisticOptions,
typescript: Boolean(enableTypeScript),
- }))
+ }));
}
if (enableUnoCSS) {
configs.push(unocss({
- ...resolveSubOptions(options, 'unocss'),
- overrides: getOverrides(options, 'unocss'),
- }))
+ ...resolveSubOptions(options, "unocss"),
+ overrides: getOverrides(options, "unocss"),
+ }));
}
if (enableI18n) {
- configs.push(i18n())
+ configs.push(i18n());
}
if (enableSecurity) {
- configs.push(security())
+ configs.push(security());
}
if (enableTailwindCSS) {
- configs.push(tailwindcss())
+ configs.push(tailwindcss());
}
if (enableAstro) {
configs.push(astro({
- overrides: getOverrides(options, 'astro'),
+ overrides: getOverrides(options, "astro"),
stylistic: stylisticOptions,
- }))
+ }));
}
if (enableStorybook) {
- configs.push(storybook())
+ configs.push(storybook());
}
if (options.jsonc ?? true) {
configs.push(
jsonc({
- overrides: getOverrides(options, 'jsonc'),
+ overrides: getOverrides(options, "jsonc"),
stylistic: stylisticOptions,
}),
sortPackageJson(),
sortTsconfig(),
- )
+ );
}
if (options.yaml ?? true) {
configs.push(yaml({
- overrides: getOverrides(options, 'yaml'),
+ overrides: getOverrides(options, "yaml"),
stylistic: stylisticOptions,
- }))
+ }));
}
if (options.toml ?? true) {
configs.push(toml({
- overrides: getOverrides(options, 'toml'),
+ overrides: getOverrides(options, "toml"),
stylistic: stylisticOptions,
- }))
+ }));
}
if (options.markdown ?? true) {
@@ -284,69 +284,69 @@ export function antfu(
markdown(
{
componentExts,
- overrides: getOverrides(options, 'markdown'),
+ overrides: getOverrides(options, "markdown"),
},
),
- )
+ );
}
if (options.formatters) {
configs.push(formatters(
options.formatters,
- typeof stylisticOptions === 'boolean' ? {} : stylisticOptions,
- ))
+ typeof stylisticOptions === "boolean" ? {} : stylisticOptions,
+ ));
}
- configs.push(prettier())
+ configs.push(prettier());
// User can optionally pass a flat config item to the first argument
// We pick the known keys as ESLint would do schema validation
const fusedConfig = flatConfigProps.reduce((acc, key) => {
if (key in options)
- acc[key] = options[key] as any
- return acc
- }, {} as TypedFlatConfigItem)
+ acc[key] = options[key] as any;
+ return acc;
+ }, {} as TypedFlatConfigItem);
if (Object.keys(fusedConfig).length > 0)
- configs.push([fusedConfig])
+ configs.push([fusedConfig]);
- let composer = new FlatConfigComposer()
+ let composer = new FlatConfigComposer();
composer = composer
.append(
...configs,
...userConfigs as any,
- )
+ );
// if (autoRenamePlugins) {
// composer = composer
// .renamePlugins(defaultPluginRenaming)
// }
- return composer
+ return composer;
}
export type ResolvedOptions = T extends boolean
? never
- : NonNullable
+ : NonNullable;
export function resolveSubOptions(
options: OptionsConfig,
key: K,
): ResolvedOptions {
- return typeof options[key] === 'boolean'
+ return typeof options[key] === "boolean"
? {} as any
- : options[key] || {}
+ : options[key] || {};
}
export function getOverrides(
options: OptionsConfig,
key: K,
) {
- const sub = resolveSubOptions(options, key)
+ const sub = resolveSubOptions(options, key);
return {
...(options.overrides as any)?.[key],
- ...'overrides' in sub
+ ..."overrides" in sub
? sub.overrides
: {},
- }
+ };
}
diff --git a/src/globs.ts b/src/globs.ts
index a423c50640..a6511c67c8 100644
--- a/src/globs.ts
+++ b/src/globs.ts
@@ -1,34 +1,34 @@
-export const GLOB_SRC_EXT = '?([cm])[jt]s?(x)'
-export const GLOB_SRC = '**/*.?([cm])[jt]s?(x)'
+export const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
+export const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
-export const GLOB_JS = '**/*.?([cm])js'
-export const GLOB_JSX = '**/*.?([cm])jsx'
+export const GLOB_JS = "**/*.?([cm])js";
+export const GLOB_JSX = "**/*.?([cm])jsx";
-export const GLOB_TS = '**/*.?([cm])ts'
-export const GLOB_TSX = '**/*.?([cm])tsx'
+export const GLOB_TS = "**/*.?([cm])ts";
+export const GLOB_TSX = "**/*.?([cm])tsx";
-export const GLOB_STYLE = '**/*.{c,le,sc}ss'
-export const GLOB_CSS = '**/*.css'
-export const GLOB_POSTCSS = '**/*.{p,post}css'
-export const GLOB_LESS = '**/*.less'
-export const GLOB_SCSS = '**/*.scss'
+export const GLOB_STYLE = "**/*.{c,le,sc}ss";
+export const GLOB_CSS = "**/*.css";
+export const GLOB_POSTCSS = "**/*.{p,post}css";
+export const GLOB_LESS = "**/*.less";
+export const GLOB_SCSS = "**/*.scss";
-export const GLOB_JSON = '**/*.json'
-export const GLOB_JSON5 = '**/*.json5'
-export const GLOB_JSONC = '**/*.jsonc'
+export const GLOB_JSON = "**/*.json";
+export const GLOB_JSON5 = "**/*.json5";
+export const GLOB_JSONC = "**/*.jsonc";
-export const GLOB_MARKDOWN = '**/*.md'
-export const GLOB_MARKDOWN_IN_MARKDOWN = '**/*.md/*.md'
-export const GLOB_SVELTE = '**/*.svelte'
-export const GLOB_VUE = '**/*.vue'
-export const GLOB_YAML = '**/*.y?(a)ml'
-export const GLOB_TOML = '**/*.toml'
-export const GLOB_XML = '**/*.xml'
-export const GLOB_HTML = '**/*.htm?(l)'
-export const GLOB_ASTRO = '**/*.astro'
-export const GLOB_GRAPHQL = '**/*.{g,graph}ql'
+export const GLOB_MARKDOWN = "**/*.md";
+export const GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
+export const GLOB_SVELTE = "**/*.svelte";
+export const GLOB_VUE = "**/*.vue";
+export const GLOB_YAML = "**/*.y?(a)ml";
+export const GLOB_TOML = "**/*.toml";
+export const GLOB_XML = "**/*.xml";
+export const GLOB_HTML = "**/*.htm?(l)";
+export const GLOB_ASTRO = "**/*.astro";
+export const GLOB_GRAPHQL = "**/*.{g,graph}ql";
-export const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`
+export const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
export const GLOB_TESTS = [
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
@@ -36,7 +36,7 @@ export const GLOB_TESTS = [
`**/*.test.${GLOB_SRC_EXT}`,
`**/*.bench.${GLOB_SRC_EXT}`,
`**/*.benchmark.${GLOB_SRC_EXT}`,
-]
+];
export const GLOB_ALL_SRC = [
GLOB_SRC,
@@ -49,38 +49,38 @@ export const GLOB_ALL_SRC = [
GLOB_YAML,
GLOB_XML,
GLOB_HTML,
-]
+];
export const GLOB_EXCLUDE = [
- '**/node_modules',
- '**/dist',
- '**/package-lock.json',
- '**/yarn.lock',
- '**/pnpm-lock.yaml',
- '**/bun.lockb',
+ "**/node_modules",
+ "**/dist",
+ "**/package-lock.json",
+ "**/yarn.lock",
+ "**/pnpm-lock.yaml",
+ "**/bun.lockb",
- '**/output',
- '**/coverage',
- '**/temp',
- '**/.temp',
- '**/tmp',
- '**/.tmp',
- '**/.history',
- '**/.vitepress/cache',
- '**/.nuxt',
- '**/.next',
- '**/.vercel',
- '**/.changeset',
- '**/.idea',
- '**/.cache',
- '**/.output',
- '**/.vite-inspect',
- '**/.yarn',
+ "**/output",
+ "**/coverage",
+ "**/temp",
+ "**/.temp",
+ "**/tmp",
+ "**/.tmp",
+ "**/.history",
+ "**/.vitepress/cache",
+ "**/.nuxt",
+ "**/.next",
+ "**/.vercel",
+ "**/.changeset",
+ "**/.idea",
+ "**/.cache",
+ "**/.output",
+ "**/.vite-inspect",
+ "**/.yarn",
- '**/CHANGELOG*.md',
- '**/*.min.*',
- '**/LICENSE*',
- '**/__snapshots__',
- '**/auto-import?(s).d.ts',
- '**/components.d.ts',
-]
+ "**/CHANGELOG*.md",
+ "**/*.min.*",
+ "**/LICENSE*",
+ "**/__snapshots__",
+ "**/auto-import?(s).d.ts",
+ "**/components.d.ts",
+];
diff --git a/src/index.ts b/src/index.ts
index f2de2f10eb..61929a19fb 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,7 +1,7 @@
-export * from './configs'
-export * from './factory'
-export * from './globs'
-export * from './types'
-export * from './utils'
+export * from "./configs";
+export * from "./factory";
+export * from "./globs";
+export * from "./types";
+export * from "./utils";
-export { antfu as default } from './factory'
+export { antfu as default } from "./factory";
diff --git a/src/plugins.ts b/src/plugins.ts
index a08ea07e1b..72d749e625 100644
--- a/src/plugins.ts
+++ b/src/plugins.ts
@@ -1,15 +1,15 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
-export { default as pluginAntfu } from 'eslint-plugin-antfu'
-export { default as pluginComments } from 'eslint-plugin-eslint-comments'
-export * as pluginImport from 'eslint-plugin-import-x'
-export { default as pluginNode } from 'eslint-plugin-n'
-export { default as pluginUnicorn } from 'eslint-plugin-unicorn'
-export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports'
-export { default as pluginPerfectionist } from 'eslint-plugin-perfectionist'
-export { default as js } from '@eslint/js'
-export { default as confusingBrowserGlobals } from 'confusing-browser-globals'
-export { default as arrayFunc } from 'eslint-plugin-array-func'
-export { default as eslintPluginNoUseExtendNative } from 'eslint-plugin-no-use-extend-native'
-export { default as eslintConfigPrettier } from 'eslint-config-prettier'
+export { default as pluginAntfu } from "eslint-plugin-antfu";
+export { default as pluginComments } from "eslint-plugin-eslint-comments";
+export * as pluginImport from "eslint-plugin-import-x";
+export { default as pluginNode } from "eslint-plugin-n";
+export { default as pluginUnicorn } from "eslint-plugin-unicorn";
+export { default as pluginUnusedImports } from "eslint-plugin-unused-imports";
+export { default as pluginPerfectionist } from "eslint-plugin-perfectionist";
+export { default as js } from "@eslint/js";
+export { default as confusingBrowserGlobals } from "confusing-browser-globals";
+export { default as arrayFunc } from "eslint-plugin-array-func";
+export { default as eslintPluginNoUseExtendNative } from "eslint-plugin-no-use-extend-native";
+export { default as eslintConfigPrettier } from "eslint-config-prettier";
diff --git a/src/stub.d.ts b/src/stub.d.ts
index 4dcc5b2ebd..b1538213d7 100644
--- a/src/stub.d.ts
+++ b/src/stub.d.ts
@@ -1,2 +1,2 @@
-declare module 'eslint-plugin-react-hooks'
-declare module 'eslint-plugin-react-refresh'
+declare module "eslint-plugin-react-hooks"
+declare module "eslint-plugin-react-refresh"
diff --git a/src/types.ts b/src/types.ts
index 9e92c56188..17d6a7d100 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -1,29 +1,29 @@
-import type { FlatGitignoreOptions } from 'eslint-config-flat-gitignore'
-import type { ParserOptions } from '@typescript-eslint/parser'
-import type { Options as VueBlocksOptions } from 'eslint-processor-vue-blocks'
-import type { Linter } from 'eslint'
-import type { StylisticCustomizeOptions } from '@stylistic/eslint-plugin'
-import type { VendoredPrettierOptions } from './vender/prettier-types'
-import type { RuleOptions } from './typegen'
+import type { FlatGitignoreOptions } from "eslint-config-flat-gitignore";
+import type { ParserOptions } from "@typescript-eslint/parser";
+import type { Options as VueBlocksOptions } from "eslint-processor-vue-blocks";
+import type { Linter } from "eslint";
+import type { StylisticCustomizeOptions } from "@stylistic/eslint-plugin";
+import type { VendoredPrettierOptions } from "./vender/prettier-types";
+import type { RuleOptions } from "./typegen";
-export type Awaitable = T | Promise
+export type Awaitable = T | Promise;
-export type Rules = RuleOptions
+export type Rules = RuleOptions;
-export type TypedFlatConfigItem = Omit, 'plugins'> & {
+export type TypedFlatConfigItem = Omit, "plugins"> & {
// Relax plugins type limitation, as most of the plugins did not have correct type info yet.
/**
* An object containing a name-value mapping of plugin names to plugin objects. When `files` is specified, these plugins are only available to the matching files.
* @see [Using plugins in your configuration](https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new#using-plugins-in-your-configuration)
*/
- plugins?: Record
-}
+ plugins?: Record;
+};
export interface OptionsFiles {
/**
* Override the `files` option to provide custom globs.
*/
- files?: Array
+ files?: Array;
}
export interface OptionsVue extends OptionsOverrides {
@@ -32,18 +32,18 @@ export interface OptionsVue extends OptionsOverrides {
* @see https://github.com/antfu/eslint-processor-vue-blocks
* @default true
*/
- sfcBlocks?: boolean | VueBlocksOptions
+ sfcBlocks?: boolean | VueBlocksOptions;
/**
* Vue version. Apply different rules set from `eslint-plugin-vue`.
* @default 3
*/
- vueVersion?: 2 | 3
+ vueVersion?: 2 | 3;
}
export type OptionsTypescript =
(OptionsTypeScriptWithTypes & OptionsOverrides)
- | (OptionsTypeScriptParserOptions & OptionsOverrides)
+ | (OptionsTypeScriptParserOptions & OptionsOverrides);
export interface OptionsFormatters {
/**
@@ -51,23 +51,23 @@ export interface OptionsFormatters {
*
* Currently only support Prettier.
*/
- css?: 'prettier' | boolean
+ css?: "prettier" | boolean;
/**
* Enable formatting support for HTML.
*
* Currently only support Prettier.
*/
- html?: 'prettier' | boolean
+ html?: "prettier" | boolean;
/**
* Enable formatting support for XML.
*
* Currently only support Prettier.
*/
- xml?: 'prettier' | boolean
+ xml?: "prettier" | boolean;
- tailwindcss?: 'prettier' | boolean
+ tailwindcss?: "prettier" | boolean;
/**
* Enable formatting support for Markdown.
@@ -76,26 +76,26 @@ export interface OptionsFormatters {
*
* When set to `true`, it will use Prettier.
*/
- markdown?: 'prettier' | 'dprint' | boolean
+ markdown?: "prettier" | "dprint" | boolean;
/**
* Enable formatting support for GraphQL.
*/
- graphql?: 'prettier' | boolean
+ graphql?: "prettier" | boolean;
/**
* Custom options for Prettier.
*
* By default it's controlled by our own config.
*/
- prettierOptions?: VendoredPrettierOptions
+ prettierOptions?: VendoredPrettierOptions;
/**
* Custom options for dprint.
*
* By default it's controlled by our own config.
*/
- dprintOptions?: boolean
+ dprintOptions?: boolean;
/**
* Install the prettier plugin for handle Slidev markdown
@@ -103,15 +103,15 @@ export interface OptionsFormatters {
* Only works when `markdown` is enabled with `prettier`.
*/
slidev?: boolean | {
- files?: Array
- }
+ files?: Array;
+ };
/**
* Enable formatting support for Astro.
*
* Currently only support Prettier.
*/
- astro?: 'prettier' | boolean
+ astro?: "prettier" | boolean;
}
export interface OptionsComponentExts {
@@ -120,20 +120,20 @@ export interface OptionsComponentExts {
* @example ['vue']
* @default []
*/
- componentExts?: Array
+ componentExts?: Array;
}
export interface OptionsTypeScriptParserOptions {
/**
* Additional parser options for TypeScript.
*/
- parserOptions?: Partial
+ parserOptions?: Partial;
/**
* Glob patterns for files that should be type aware.
* @default ['**\/*.{ts,tsx}']
*/
- filesTypeAware?: Array
+ filesTypeAware?: Array;
}
export interface OptionsTypeScriptWithTypes {
@@ -141,32 +141,32 @@ export interface OptionsTypeScriptWithTypes {
* When this options is provided, type aware rules will be enabled.
* @see https://typescript-eslint.io/linting/typed-linting/
*/
- tsconfigPath?: string | Array
+ tsconfigPath?: string | Array;
}
export interface OptionsHasTypeScript {
- typescript?: boolean
+ typescript?: boolean;
}
export interface OptionsStylistic {
- stylistic?: boolean | StylisticConfig
+ stylistic?: boolean | StylisticConfig;
}
-export type StylisticConfig = Pick
+export type StylisticConfig = Pick;
export interface OptionsOverrides {
- overrides?: TypedFlatConfigItem['rules']
+ overrides?: TypedFlatConfigItem["rules"];
}
export interface OptionsRegExp {
/**
* Override rulelevels
*/
- level?: 'error' | 'warn'
+ level?: "error" | "warn";
}
export interface OptionsIsInEditor {
- isInEditor?: boolean
+ isInEditor?: boolean;
}
export interface OptionsUnoCSS extends OptionsOverrides {
@@ -174,12 +174,12 @@ export interface OptionsUnoCSS extends OptionsOverrides {
* Enable attributify support.
* @default true
*/
- attributify?: boolean
+ attributify?: boolean;
/**
* Enable strict mode by throwing errors about blocklisted classes.
* @default false
*/
- strict?: boolean
+ strict?: boolean;
}
export interface OptionsConfig extends OptionsComponentExts {
@@ -190,7 +190,7 @@ export interface OptionsConfig extends OptionsComponentExts {
* @see https://github.com/antfu/eslint-config-flat-gitignore
* @default true
*/
- gitignore?: boolean | FlatGitignoreOptions
+ gitignore?: boolean | FlatGitignoreOptions;
/**
* Disable some opinionated rules to Anthony's preference.
@@ -200,17 +200,17 @@ export interface OptionsConfig extends OptionsComponentExts {
* - `antfu/if-newline`
* @default false
*/
- lessOpinionated?: boolean
+ lessOpinionated?: boolean;
- tailwindcss?: boolean
- storybook?: boolean
- i18n?: boolean
- security?: boolean
+ tailwindcss?: boolean;
+ storybook?: boolean;
+ i18n?: boolean;
+ security?: boolean;
/**
* Core rules. Can't be disabled.
*/
- javascript?: OptionsOverrides
+ javascript?: OptionsOverrides;
/**
* Enable TypeScript support.
@@ -218,7 +218,7 @@ export interface OptionsConfig extends OptionsComponentExts {
* Passing an object to enable TypeScript Language Server support.
* @default auto-detect based on the dependencies
*/
- typescript?: boolean | OptionsTypescript
+ typescript?: boolean | OptionsTypescript;
/**
* Enable JSX related rules.
@@ -226,37 +226,37 @@ export interface OptionsConfig extends OptionsComponentExts {
* Currently only stylistic rules are included.
* @default true
*/
- jsx?: boolean
+ jsx?: boolean;
/**
* Enable test support.
* @default true
*/
- test?: boolean | OptionsOverrides
+ test?: boolean | OptionsOverrides;
/**
* Enable Vue support.
* @default auto-detect based on the dependencies
*/
- vue?: boolean | OptionsVue
+ vue?: boolean | OptionsVue;
/**
* Enable JSONC support.
* @default true
*/
- jsonc?: boolean | OptionsOverrides
+ jsonc?: boolean | OptionsOverrides;
/**
* Enable YAML support.
* @default true
*/
- yaml?: boolean | OptionsOverrides
+ yaml?: boolean | OptionsOverrides;
/**
* Enable TOML support.
* @default true
*/
- toml?: boolean | OptionsOverrides
+ toml?: boolean | OptionsOverrides;
/**
* Enable ASTRO support.
@@ -268,7 +268,7 @@ export interface OptionsConfig extends OptionsComponentExts {
* - `prettier-plugin-astro`
* @default false
*/
- astro?: boolean | OptionsOverrides
+ astro?: boolean | OptionsOverrides;
/**
* Enable linting for **code snippets** in Markdown.
@@ -276,21 +276,21 @@ export interface OptionsConfig extends OptionsComponentExts {
* For formatting Markdown content, enable also `formatters.markdown`.
* @default true
*/
- markdown?: boolean | OptionsOverrides
+ markdown?: boolean | OptionsOverrides;
/**
* Enable stylistic rules.
* @see https://eslint.style/
* @default true
*/
- stylistic?: boolean | (StylisticConfig & OptionsOverrides)
+ stylistic?: boolean | (StylisticConfig & OptionsOverrides);
/**
* Enable regexp rules.
* @see https://ota-meshi.github.io/eslint-plugin-regexp/
* @default true
*/
- regexp?: boolean | (OptionsRegExp & OptionsOverrides)
+ regexp?: boolean | (OptionsRegExp & OptionsOverrides);
/**
* Enable react rules.
@@ -301,7 +301,7 @@ export interface OptionsConfig extends OptionsComponentExts {
* - `eslint-plugin-react-refresh`
* @default false
*/
- react?: boolean | OptionsOverrides
+ react?: boolean | OptionsOverrides;
/**
* Enable solid rules.
*
@@ -309,7 +309,7 @@ export interface OptionsConfig extends OptionsComponentExts {
* - `eslint-plugin-solid`
* @default false
*/
- solid?: boolean | OptionsOverrides
+ solid?: boolean | OptionsOverrides;
/**
* Enable svelte rules.
@@ -318,7 +318,7 @@ export interface OptionsConfig extends OptionsComponentExts {
* - `eslint-plugin-svelte`
* @default false
*/
- svelte?: boolean
+ svelte?: boolean;
/**
* Enable unocss rules.
@@ -327,7 +327,7 @@ export interface OptionsConfig extends OptionsComponentExts {
* - `@unocss/eslint-plugin`
* @default false
*/
- unocss?: boolean | OptionsUnoCSS
+ unocss?: boolean | OptionsUnoCSS;
/**
* Use external formatters to format files.
@@ -338,13 +338,13 @@ export interface OptionsConfig extends OptionsComponentExts {
* When set to `true`, it will enable all formatters.
* @default false
*/
- formatters?: boolean | OptionsFormatters
+ formatters?: boolean | OptionsFormatters;
/**
* Control to disable some rules in editors.
* @default auto-detect based on the process.env
*/
- isInEditor?: boolean
+ isInEditor?: boolean;
// /**
// * Automatically rename plugins in the config.
@@ -358,18 +358,18 @@ export interface OptionsConfig extends OptionsComponentExts {
* @deprecated use `overrides` option in each integration key instead
*/
overrides?: {
- stylistic?: TypedFlatConfigItem['rules']
- javascript?: TypedFlatConfigItem['rules']
- typescript?: TypedFlatConfigItem['rules']
- test?: TypedFlatConfigItem['rules']
- vue?: TypedFlatConfigItem['rules']
- jsonc?: TypedFlatConfigItem['rules']
- markdown?: TypedFlatConfigItem['rules']
- yaml?: TypedFlatConfigItem['rules']
- toml?: TypedFlatConfigItem['rules']
- react?: TypedFlatConfigItem['rules']
- svelte?: TypedFlatConfigItem['rules']
- }
+ stylistic?: TypedFlatConfigItem["rules"];
+ javascript?: TypedFlatConfigItem["rules"];
+ typescript?: TypedFlatConfigItem["rules"];
+ test?: TypedFlatConfigItem["rules"];
+ vue?: TypedFlatConfigItem["rules"];
+ jsonc?: TypedFlatConfigItem["rules"];
+ markdown?: TypedFlatConfigItem["rules"];
+ yaml?: TypedFlatConfigItem["rules"];
+ toml?: TypedFlatConfigItem["rules"];
+ react?: TypedFlatConfigItem["rules"];
+ svelte?: TypedFlatConfigItem["rules"];
+ };
}
-export { type ConfigNames } from './typegen'
+export { type ConfigNames } from "./typegen";
diff --git a/src/utils.ts b/src/utils.ts
index 82a2aef07c..21c6ede00b 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,10 +1,10 @@
-import process from 'node:process'
-import { isPackageExists } from 'local-pkg'
-import type { Awaitable, TypedFlatConfigItem } from './types'
+import process from "node:process";
+import { isPackageExists } from "local-pkg";
+import type { Awaitable, TypedFlatConfigItem } from "./types";
export const parserPlain = {
meta: {
- name: 'parser-plain',
+ name: "parser-plain",
},
parseForESLint: (code: string) => ({
ast: {
@@ -13,7 +13,7 @@ export const parserPlain = {
loc: { end: code.length, start: 0 },
range: [0, code.length],
tokens: [],
- type: 'Program',
+ type: "Program",
},
scopeManager: null,
services: { isPlain: true },
@@ -21,15 +21,15 @@ export const parserPlain = {
Program: [],
},
}),
-}
+};
/**
* Combine array and non-array configs into a single array.
* @param {...any} configs
*/
export async function combine(...configs: Array>>): Promise> {
- const resolved = await Promise.all(configs)
- return resolved.flat()
+ const resolved = await Promise.all(configs);
+ return resolved.flat();
}
/**
@@ -57,11 +57,11 @@ export function renameRules(rules: Record, map: Record {
for (const [from, to] of Object.entries(map)) {
if (key.startsWith(`${from}/`))
- return [to + key.slice(from.length), value]
+ return [to + key.slice(from.length), value];
}
- return [key, value]
+ return [key, value];
}),
- )
+ );
}
/**
@@ -81,44 +81,44 @@ export function renameRules(rules: Record, map: Record, map: Record): Array {
return configs.map((i) => {
- const clone = { ...i }
+ const clone = { ...i };
if (clone.rules)
- clone.rules = renameRules(clone.rules, map)
+ clone.rules = renameRules(clone.rules, map);
if (clone.plugins) {
clone.plugins = Object.fromEntries(
Object.entries(clone.plugins)
.map(([key, value]) => {
if (key in map)
- return [map[key], value]
- return [key, value]
+ return [map[key], value];
+ return [key, value];
}),
- )
+ );
}
- return clone
- })
+ return clone;
+ });
}
export function toArray(value: T | Array): Array {
- return Array.isArray(value) ? value : [value]
+ return Array.isArray(value) ? value : [value];
}
export async function interopDefault(m: Awaitable): Promise {
- const resolved = await m
- return (resolved as any).default || resolved
+ const resolved = await m;
+ return (resolved as any).default || resolved;
}
export async function ensurePackages(packages: Array) {
if (process.env.CI || process.stdout.isTTY === false)
- return
+ return;
- const nonExistingPackages = packages.filter(i => i && !isPackageExists(i)) as Array
+ const nonExistingPackages = packages.filter(i => i && !isPackageExists(i)) as Array;
if (nonExistingPackages.length === 0)
- return
+ return;
- const p = await import('@clack/prompts')
+ const p = await import("@clack/prompts");
const result = await p.confirm({
- message: `${nonExistingPackages.length === 1 ? 'Package is' : 'Packages are'} required for this config: ${nonExistingPackages.join(', ')}. Do you want to install them?`,
- })
+ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
+ });
if (result)
- await import('@antfu/install-pkg').then(i => i.installPackage(nonExistingPackages, { dev: true }))
+ await import("@antfu/install-pkg").then(i => i.installPackage(nonExistingPackages, { dev: true }));
}
diff --git a/src/vender/prettier-types.ts b/src/vender/prettier-types.ts
index c9c18cd159..30c6d80f95 100644
--- a/src/vender/prettier-types.ts
+++ b/src/vender/prettier-types.ts
@@ -2,149 +2,149 @@
* Vendor types from Prettier so we don't rely on the dependency.
*/
-export type VendoredPrettierOptions = Partial
+export type VendoredPrettierOptions = Partial;
export interface VendoredPrettierOptionsRequired {
/**
* Specify the line length that the printer will wrap on.
* @default 120
*/
- printWidth: number
+ printWidth: number;
/**
* Specify the number of spaces per indentation-level.
*/
- tabWidth: number
+ tabWidth: number;
/**
* Indent lines with tabs instead of spaces
*/
- useTabs?: boolean
+ useTabs?: boolean;
/**
* Print semicolons at the ends of statements.
*/
- semi: boolean
+ semi: boolean;
/**
* Use single quotes instead of double quotes.
*/
- singleQuote: boolean
+ singleQuote: boolean;
/**
* Use single quotes in JSX.
*/
- jsxSingleQuote: boolean
+ jsxSingleQuote: boolean;
/**
* Print trailing commas wherever possible.
*/
- trailingComma: 'none' | 'es5' | 'all'
+ trailingComma: "none" | "es5" | "all";
/**
* Print spaces between brackets in object literals.
*/
- bracketSpacing: boolean
+ bracketSpacing: boolean;
/**
* Put the `>` of a multi-line HTML (HTML, XML, JSX, Vue, Angular) element at the end of the last line instead of being
* alone on the next line (does not apply to self closing elements).
*/
- bracketSameLine: boolean
+ bracketSameLine: boolean;
/**
* Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line.
* @deprecated use bracketSameLine instead
*/
- jsxBracketSameLine: boolean
+ jsxBracketSameLine: boolean;
/**
* Format only a segment of a file.
*/
- rangeStart: number
+ rangeStart: number;
/**
* Format only a segment of a file.
* @default Number.POSITIVE_INFINITY
*/
- rangeEnd: number
+ rangeEnd: number;
/**
* By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer.
* In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out.
* @default "preserve"
*/
- proseWrap: 'always' | 'never' | 'preserve'
+ proseWrap: "always" | "never" | "preserve";
/**
* Include parentheses around a sole arrow function parameter.
* @default "always"
*/
- arrowParens: 'avoid' | 'always'
+ arrowParens: "avoid" | "always";
/**
* Provide ability to support new languages to prettier.
*/
- plugins: Array
+ plugins: Array;
/**
* How to handle whitespaces in HTML.
* @default "css"
*/
- htmlWhitespaceSensitivity: 'css' | 'strict' | 'ignore'
+ htmlWhitespaceSensitivity: "css" | "strict" | "ignore";
/**
* Which end of line characters to apply.
* @default "lf"
*/
- endOfLine: 'auto' | 'lf' | 'crlf' | 'cr'
+ endOfLine: "auto" | "lf" | "crlf" | "cr";
/**
* Change when properties in objects are quoted.
* @default "as-needed"
*/
- quoteProps: 'as-needed' | 'consistent' | 'preserve'
+ quoteProps: "as-needed" | "consistent" | "preserve";
/**
* Whether or not to indent the code inside