diff --git a/README.md b/README.md index 870acf6d30..aa37b65d59 100644 --- a/README.md +++ b/README.md @@ -29,14 +29,7 @@ pnpm add -D eslint @antfu/eslint-config // eslint.config.js import antfu from '@antfu/eslint-config' -export default [ - ...antfu, - { - rules: { - // your overrides - }, - }, -] +export default antfu() ``` > You don't need `.eslintignore` normally as it has been provided by the preset. @@ -81,7 +74,11 @@ Add the following settings to your `settings.json`: { "rule": "*-indent", "severity": "off" }, { "rule": "*-spacing", "severity": "off" }, { "rule": "*-spaces", "severity": "off" }, - { "rule": "*-order", "severity": "off" } + { "rule": "*-order", "severity": "off" }, + { "rule": "*-dangle", "severity": "off" }, + { "rule": "*-newline", "severity": "off" }, + { "rule": "*quotes", "severity": "off" }, + { "rule": "*semi", "severity": "off" } ], // The following is optional. @@ -107,28 +104,53 @@ Add the following settings to your `settings.json`: Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), provides a much better organization and composition. -You can now compose your own config easily: +Normally you only need to import the `antfu` preset: ```js // eslint.config.js -import { - presetAuto, - presetJavaScriptCore, - presetLangsExtensions, - presetTypeScript, -} from '@antfu/eslint-config' +import antfu from '@antfu/eslint-config' -export default [ - // javascript, node, unicorn, jsdoc, imports, etc. - ...presetJavaScriptCore, - // typescript support - ...presetTypeScript, - // yaml, markdown, json, support - ...presetLangsExtensions, -] +export default antfu() ``` -Or even more granular: +You can configure each feature individually, for example: + +```js +// eslint.config.js +import antfu from '@antfu/eslint-config' + +export default antfu({ + stylistic: true, // enable stylistic formatting rules + typescript: true, + vue: true, + jsonc: false, + yml: false, +}) +``` + +The `antfu` factory functions also accepts arbitrary numbers of constom configs overrides: + +```js +// eslint.config.js +import antfu from '@antfu/eslint-config' + +export default antfu( + { + // Configures for antfu's config + }, + + // From the second arguments they are ESLint Flat Configs + // you can have multiple configs + { + rules: {}, + }, + { + rules: {}, + }, +) +``` + +Going more advanced, you can also import the very fine-grained configs and compose them as you wish: ```js // eslint.config.js @@ -153,7 +175,7 @@ import { export default [ ...ignores, - ...javascript, + ...javascript(), ...comments, ...node, ...jsdoc, @@ -161,40 +183,33 @@ export default [ ...unicorn, ...javascriptStylistic, - ...typescript, + ...typescript(), ...typescriptStylistic, - ...vue, - + ...vue(), ...jsonc, ...yml, - ...markdown, + ...markdown(), ] ``` -Check out the [presets](https://github.com/antfu/eslint-config/blob/main/packages/eslint-config/src/presets.ts) and [configs](https://github.com/antfu/eslint-config/blob/main/packages/eslint-config/src/configs) for more details. +Check out the [configs](https://github.com/antfu/eslint-config/blob/main/packages/eslint-config/src/configs) and [factory](https://github.com/antfu/eslint-config/blob/main/packages/eslint-config/src/factory.ts) for more details. > Thanks to [sxzz/eslint-config](https://github.com/sxzz/eslint-config) for the inspiration and reference. ### Type Aware Rules -You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by importing `typescriptWithLanguageServer` config: +You can optionally enable the [type aware rules](https://typescript-eslint.io/linting/typed-linting/) by passing the options object to the `typescript` config: ```js // eslint.config.js -import { presetAuto, typescriptWithLanguageServer } from '@antfu/eslint-config' +import antfu from '@antfu/eslint-config' -export default [ - ...presetAuto, - ...typescriptWithLanguageServer({ - tsconfig: 'tsconfig.json', // path to your tsconfig - }), - { - rules: { - // your overrides - }, +export default antfu({ + typescript: { + tsconfigPath: 'tsconfig.json', }, -] +}) ``` ### Lint Staged @@ -240,7 +255,7 @@ This config does NOT lint CSS. I personally use [UnoCSS](https://github.com/unoc ### I prefer XXX... -Sure, you can override rules locally in your project to fit your needs. Or you can always fork this repo and make your own. +Sure, you can config and override rules locally in your project to fit your needs. If that still does not work for you, you can always fork this repo and maintain your own. ## Check Also diff --git a/eslint.config.js b/eslint.config.js index 58d3da3333..4be191c80f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,10 +1,9 @@ -import { defineFlatConfig } from 'eslint-define-config' -import { presetAuto } from '@antfu/eslint-config' +import antfu from '@antfu/eslint-config' import stylisticMigrate from '@stylistic/eslint-plugin-migrate' import sortKeys from 'eslint-plugin-sort-keys' -export default defineFlatConfig([ - ...presetAuto, +export default antfu( + undefined, { files: ['**/eslint-config/src/**/*.ts'], plugins: { @@ -16,4 +15,4 @@ export default defineFlatConfig([ 'sort-keys/sort-keys-fix': 'error', }, }, -]) +) diff --git a/packages/eslint-config/src/configs/markdown.ts b/packages/eslint-config/src/configs/markdown.ts index 8556dcece2..7cb609e898 100644 --- a/packages/eslint-config/src/configs/markdown.ts +++ b/packages/eslint-config/src/configs/markdown.ts @@ -1,52 +1,62 @@ import type { FlatESLintConfigItem } from 'eslint-define-config' -import { GLOB_MARKDOWN, GLOB_SRC, GLOB_VUE } from '../globs' +import { GLOB_MARKDOWN, GLOB_MARKDOWN_CODE } from '../globs' import { pluginMarkdown } from '../plugins' import { OFF } from '../flags' +import type { OptionsComponentExts } from '../types' -export const markdown: FlatESLintConfigItem[] = [ - { - files: [GLOB_MARKDOWN], - plugins: { - markdown: pluginMarkdown, +export function markdown(options: OptionsComponentExts = {}): FlatESLintConfigItem[] { + const { + componentExts = [], + } = options + + return [ + { + files: [GLOB_MARKDOWN], + plugins: { + markdown: pluginMarkdown, + }, + processor: 'markdown/markdown', }, - processor: 'markdown/markdown', - }, - { - files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, `${GLOB_MARKDOWN}/${GLOB_VUE}`], - languageOptions: { - parserOptions: { - ecmaFeatures: { - impliedStrict: true, + { + files: [ + GLOB_MARKDOWN_CODE, + ...componentExts.map(ext => `${GLOB_MARKDOWN}/**/*.${ext}`), + ], + languageOptions: { + parserOptions: { + ecmaFeatures: { + impliedStrict: true, + }, }, }, - }, - rules: { - ...pluginMarkdown.configs.recommended.overrides[1].rules, - '@typescript-eslint/comma-dangle': OFF, - '@typescript-eslint/consistent-type-imports': OFF, - '@typescript-eslint/no-namespace': OFF, - '@typescript-eslint/no-redeclare': OFF, - '@typescript-eslint/no-require-imports': OFF, - '@typescript-eslint/no-unused-vars': OFF, - '@typescript-eslint/no-use-before-define': OFF, - '@typescript-eslint/no-var-requires': OFF, + rules: { + ...pluginMarkdown.configs.recommended.overrides[1].rules, + '@typescript-eslint/comma-dangle': OFF, + '@typescript-eslint/consistent-type-imports': OFF, + '@typescript-eslint/no-namespace': OFF, + '@typescript-eslint/no-redeclare': OFF, + '@typescript-eslint/no-require-imports': OFF, + '@typescript-eslint/no-unused-vars': OFF, + '@typescript-eslint/no-use-before-define': OFF, + '@typescript-eslint/no-var-requires': OFF, - 'antfu/no-cjs-exports': OFF, - 'antfu/no-ts-export-equal': OFF, + 'antfu/no-cjs-exports': OFF, + 'antfu/no-ts-export-equal': OFF, - 'import/no-unresolved': OFF, + 'import/no-unresolved': OFF, - 'n/prefer-global/process': OFF, + 'n/prefer-global/process': OFF, - 'no-alert': OFF, - 'no-console': OFF, - 'no-restricted-imports': OFF, - 'no-undef': OFF, - 'no-unused-expressions': OFF, - 'no-unused-vars': OFF, + 'no-alert': OFF, + 'no-console': OFF, + 'no-restricted-imports': OFF, + 'no-undef': OFF, + 'no-unused-expressions': OFF, + 'no-unused-vars': OFF, - 'unused-imports/no-unused-imports': OFF, - 'unused-imports/no-unused-vars': OFF, + 'unused-imports/no-unused-imports': OFF, + 'unused-imports/no-unused-vars': OFF, + }, }, - }, -] + ] +} diff --git a/packages/eslint-config/src/configs/sort.ts b/packages/eslint-config/src/configs/sort.ts index 3a918ad380..a8d015280a 100644 --- a/packages/eslint-config/src/configs/sort.ts +++ b/packages/eslint-config/src/configs/sort.ts @@ -5,7 +5,6 @@ import type { FlatESLintConfigItem } from 'eslint-define-config' * * Requires `jsonc` config */ - export const sortPackageJson: FlatESLintConfigItem[] = [ { files: ['**/package.json'], diff --git a/packages/eslint-config/src/configs/stylistic.ts b/packages/eslint-config/src/configs/stylistic.ts index eda29a09f8..bb6e905c71 100644 --- a/packages/eslint-config/src/configs/stylistic.ts +++ b/packages/eslint-config/src/configs/stylistic.ts @@ -9,7 +9,6 @@ export const javascriptStylistic: FlatESLintConfigItem[] = [ '@stylistic/js': pluginStylisticJs, }, rules: { - // Stylistic '@stylistic/js/array-bracket-spacing': ['error', 'never'], '@stylistic/js/arrow-spacing': ['error', { after: true, before: true }], '@stylistic/js/block-spacing': ['error', 'always'], diff --git a/packages/eslint-config/src/configs/typescript.ts b/packages/eslint-config/src/configs/typescript.ts index 8d8130bfe4..af141afc8e 100644 --- a/packages/eslint-config/src/configs/typescript.ts +++ b/packages/eslint-config/src/configs/typescript.ts @@ -1,116 +1,128 @@ import process from 'node:process' import type { FlatESLintConfigItem } from 'eslint-define-config' -import { GLOB_TS, GLOB_TSX, GLOB_VUE } from '../globs' +import { GLOB_TS, GLOB_TSX } from '../globs' import { parserTs, pluginAntfu, pluginImport, pluginTs } from '../plugins' -import { hasVue } from '../env' import { OFF } from '../flags' +import type { OptionsComponentExts, OptionsTypeScriptWithLanguageServer } from '../types' -const GLOBS_TS_LIKE = [GLOB_TS, GLOB_TSX] -if (hasVue) - GLOBS_TS_LIKE.push(GLOB_VUE) +export function typescript(options?: OptionsComponentExts): FlatESLintConfigItem[] { + const { + componentExts = [], + } = options ?? {} -export const typescript: FlatESLintConfigItem[] = [ - { - files: GLOBS_TS_LIKE, - languageOptions: { - parser: parserTs, - parserOptions: { - sourceType: 'module', + return [ + { + files: [ + GLOB_TS, + GLOB_TSX, + ...componentExts.map(ext => `**/*.${ext}`), + ], + languageOptions: { + parser: parserTs, + parserOptions: { + sourceType: 'module', + }, }, - }, - plugins: { - '@typescript-eslint': pluginTs as any, - 'antfu': pluginAntfu, - 'import': pluginImport, - }, - rules: { - ...pluginTs.configs['eslint-recommended'].overrides![0].rules, - ...pluginTs.configs.strict.rules, + plugins: { + '@typescript-eslint': pluginTs as any, + 'antfu': pluginAntfu, + 'import': pluginImport, + }, + rules: { + ...pluginTs.configs['eslint-recommended'].overrides![0].rules, + ...pluginTs.configs.strict.rules, - // TS - '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }], - '@typescript-eslint/ban-ts-ignore': OFF, - '@typescript-eslint/comma-dangle': ['error', 'always-multiline'], - '@typescript-eslint/consistent-indexed-object-style': OFF, - '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], - '@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false, prefer: 'type-imports' }], - '@typescript-eslint/explicit-function-return-type': OFF, - '@typescript-eslint/explicit-member-accessibility': OFF, - '@typescript-eslint/explicit-module-boundary-types': OFF, - '@typescript-eslint/naming-convention': OFF, - '@typescript-eslint/no-dupe-class-members': 'error', - '@typescript-eslint/no-empty-function': OFF, - '@typescript-eslint/no-empty-interface': OFF, - '@typescript-eslint/no-explicit-any': OFF, - '@typescript-eslint/no-extra-parens': ['error', 'functions'], - '@typescript-eslint/no-invalid-this': 'error', - '@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/parameter-properties': OFF, - '@typescript-eslint/prefer-ts-expect-error': 'error', - '@typescript-eslint/quotes': ['error', 'single'], - '@typescript-eslint/semi': ['error', 'never'], - '@typescript-eslint/triple-slash-reference': OFF, + // TS + '@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }], + '@typescript-eslint/ban-ts-ignore': OFF, + '@typescript-eslint/comma-dangle': ['error', 'always-multiline'], + '@typescript-eslint/consistent-indexed-object-style': OFF, + '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], + '@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false, prefer: 'type-imports' }], + '@typescript-eslint/explicit-function-return-type': OFF, + '@typescript-eslint/explicit-member-accessibility': OFF, + '@typescript-eslint/explicit-module-boundary-types': OFF, + '@typescript-eslint/naming-convention': OFF, + '@typescript-eslint/no-dupe-class-members': 'error', + '@typescript-eslint/no-empty-function': OFF, + '@typescript-eslint/no-empty-interface': OFF, + '@typescript-eslint/no-explicit-any': OFF, + '@typescript-eslint/no-extra-parens': ['error', 'functions'], + '@typescript-eslint/no-invalid-this': 'error', + '@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/parameter-properties': OFF, + '@typescript-eslint/prefer-ts-expect-error': 'error', + '@typescript-eslint/quotes': ['error', 'single'], + '@typescript-eslint/semi': ['error', 'never'], + '@typescript-eslint/triple-slash-reference': OFF, - 'antfu/generic-spacing': 'error', - 'antfu/named-tuple-spacing': 'error', - 'antfu/no-cjs-exports': 'error', - 'antfu/no-const-enum': 'error', - 'antfu/no-ts-export-equal': 'error', + 'antfu/generic-spacing': 'error', + 'antfu/named-tuple-spacing': 'error', + 'antfu/no-cjs-exports': 'error', + 'antfu/no-const-enum': 'error', + 'antfu/no-ts-export-equal': 'error', - 'comma-dangle': OFF, - 'no-dupe-class-members': OFF, - 'no-extra-parens': OFF, - 'no-invalid-this': OFF, - 'no-loss-of-precision': OFF, - 'no-redeclare': OFF, - 'no-use-before-define': OFF, - 'no-useless-constructor': OFF, - 'quotes': OFF, - 'semi': OFF, + 'comma-dangle': OFF, + 'no-dupe-class-members': OFF, + 'no-extra-parens': OFF, + 'no-invalid-this': OFF, + 'no-loss-of-precision': OFF, + 'no-redeclare': OFF, + 'no-use-before-define': OFF, + 'no-useless-constructor': OFF, + 'quotes': OFF, + 'semi': OFF, + }, }, - }, - { - files: ['**/*.d.ts'], - rules: { - 'eslint-comments/no-unlimited-disable': OFF, - 'import/no-duplicates': OFF, - 'unused-imports/no-unused-vars': OFF, + { + files: ['**/*.d.ts'], + rules: { + 'eslint-comments/no-unlimited-disable': OFF, + 'import/no-duplicates': OFF, + 'unused-imports/no-unused-vars': OFF, + }, }, - }, - { - files: ['**/*.{test,spec}.ts?(x)'], - rules: { - 'no-unused-expressions': OFF, + { + files: ['**/*.{test,spec}.ts?(x)'], + rules: { + 'no-unused-expressions': OFF, + }, }, - }, - { - files: ['**/*.js', '**/*.cjs'], - rules: { - '@typescript-eslint/no-require-imports': OFF, - '@typescript-eslint/no-var-requires': OFF, + { + files: ['**/*.js', '**/*.cjs'], + rules: { + '@typescript-eslint/no-require-imports': OFF, + '@typescript-eslint/no-var-requires': OFF, + }, }, - }, -] + ] +} + +export function typescriptWithLanguageServer(options: OptionsTypeScriptWithLanguageServer & OptionsComponentExts): FlatESLintConfigItem[] { + const { + componentExts = [], + tsconfigPath, + tsconfigRootDir = process.cwd(), + } = options -export function typescriptWithLanguageServer({ - tsconfig, -}: { - tsconfig: string -}): FlatESLintConfigItem[] { return [ { - files: GLOBS_TS_LIKE, + files: [ + GLOB_TS, + GLOB_TSX, + ...componentExts.map(ext => `**/*.${ext}`), + ], ignores: ['**/*.md/*.*'], languageOptions: { parser: parserTs, parserOptions: { - project: [tsconfig], - tsconfigRootDir: process.cwd(), + project: [tsconfigPath], + tsconfigRootDir, }, }, plugins: { diff --git a/packages/eslint-config/src/factory.ts b/packages/eslint-config/src/factory.ts new file mode 100644 index 0000000000..1000dd1ac3 --- /dev/null +++ b/packages/eslint-config/src/factory.ts @@ -0,0 +1,93 @@ +import type { FlatESLintConfigItem } from 'eslint-define-config' +import { + comments, + ignores, + imports, + javascript, + javascriptStylistic, + jsdoc, + jsonc, + markdown, + node, + sortPackageJson, + sortTsconfig, + test, + typescript, + typescriptStylistic, + typescriptWithLanguageServer, + unicorn, + vue, + yml, +} from './configs' +import { hasTypeScript, hasVue } from './env' +import type { OptionsConfig } from './types' +import { combine } from '.' + +/** + * Construct an array of ESLint flat config items. + */ +export function antfu(options: OptionsConfig = {}, ...userConfigs: (FlatESLintConfigItem | FlatESLintConfigItem[])[]) { + const configs = [ + ignores, + javascript, + comments, + node, + jsdoc, + imports, + unicorn, + ] + + const enableVue = options.vue ?? hasVue + const enableTypeScript = options.typescript ?? hasTypeScript + const enableStylistic = options.stylistic ?? true + + // In the future we may support more component extensions like Svelte or so + const componentExts: string[] = [] + if (enableVue) + componentExts.push('vue') + + if (enableStylistic) + configs.push(javascriptStylistic) + + if (enableTypeScript) { + configs.push(typescript({ componentExts })) + + if (typeof enableTypeScript !== 'boolean') { + configs.push(typescriptWithLanguageServer({ + ...enableTypeScript, + componentExts, + })) + } + + if (enableStylistic) + configs.push(typescriptStylistic) + } + + if (options.test ?? true) + configs.push(test) + + if (enableVue) + configs.push(vue) + + if (options.jsonc ?? true) { + configs.push( + jsonc, + sortPackageJson, + sortTsconfig, + ) + } + + if (options.yaml ?? true) + configs.push(yml) + + if (options.markdown ?? true) { + configs.push(markdown({ + componentExts, + })) + } + + return combine( + ...configs, + ...userConfigs, + ) +} diff --git a/packages/eslint-config/src/globs.ts b/packages/eslint-config/src/globs.ts index 9bf569b942..512e695094 100644 --- a/packages/eslint-config/src/globs.ts +++ b/packages/eslint-config/src/globs.ts @@ -21,10 +21,12 @@ export const GLOB_VUE = '**/*.vue' export const GLOB_YAML = '**/*.y?(a)ml' export const GLOB_HTML = '**/*.htm?(l)' +export const GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}` + export const GLOB_TESTS = [ - '**/__tests__/**/*.?([cm])[jt]s?(x)', - '**/*.spec.?([cm])[jt]s?(x)', - '**/*.test.?([cm])[jt]s?(x)', + `**/__tests__/**/*.${GLOB_SRC_EXT}`, + `**/*.spec.${GLOB_SRC_EXT}`, + `**/*.test.${GLOB_SRC_EXT}`, ] export const GLOB_ALL_SRC = [ @@ -38,23 +40,16 @@ export const GLOB_ALL_SRC = [ GLOB_HTML, ] -export const GLOB_NODE_MODULES = '**/node_modules' -export const GLOB_DIST = '**/dist' -export const GLOB_LOCKFILE = [ +export const GLOB_EXCLUDE = [ + '**/node_modules', + '**/dist', '**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml', -] - -export const GLOB_EXCLUDE = [ - GLOB_NODE_MODULES, - GLOB_DIST, - ...GLOB_LOCKFILE, '**/output', '**/coverage', '**/temp', - '**/fixtures', '**/.vitepress/cache', '**/.nuxt', '**/.vercel', diff --git a/packages/eslint-config/src/index.ts b/packages/eslint-config/src/index.ts index 83ada4c8d3..b3401fcc50 100644 --- a/packages/eslint-config/src/index.ts +++ b/packages/eslint-config/src/index.ts @@ -1,9 +1,10 @@ -import { presetAuto } from './presets' - -export default presetAuto +import { antfu } from './factory' +export * from './types' +export * from './factory' export * from './configs' -export * from './presets' export * from './plugins' export * from './env' export * from './utils' + +export default antfu diff --git a/packages/eslint-config/src/presets.ts b/packages/eslint-config/src/presets.ts deleted file mode 100644 index bebcca8fda..0000000000 --- a/packages/eslint-config/src/presets.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { - comments, - ignores, - imports, - javascript, - javascriptStylistic, - jsdoc, - jsonc, - markdown, - node, - sortPackageJson, - sortTsconfig, - test, - typescript, - typescriptStylistic, - unicorn, - vue, - yml, -} from './configs' -import { hasTypeScript, hasVue } from './env' - -/** - * The fundamental preset - */ -export const presetJavaScript = [ - ...ignores, - ...javascript, - ...comments, - ...node, - ...jsdoc, - ...imports, - ...unicorn, - ...javascriptStylistic, -] - -/** - * Preset for TypeScript - */ -export const presetTypeScript = [ - ...typescript, - ...typescriptStylistic, -] - -/** - * Preset for Markdown, JSONC, YAML - */ -export const presetLangsExtensions = [ - ...markdown, - ...yml, - ...jsonc, - ...sortPackageJson, - ...sortTsconfig, -] - -/** - * The full preset - * - * Automatically detects TypeScript and Vue rules based on the dependencies - */ -export const presetAuto = [ - ...presetJavaScript, - - // ts - ...hasTypeScript ? presetTypeScript : [], - - ...test, - - // vue - ...hasVue ? vue : [], - - // language extensions - ...presetLangsExtensions, -] - -/** - * Include rules for all supported integrations - */ -export const presetAll = [ - ...presetJavaScript, - ...presetTypeScript, - ...test, - ...vue, - ...presetLangsExtensions, -] diff --git a/packages/eslint-config/src/types.ts b/packages/eslint-config/src/types.ts new file mode 100644 index 0000000000..3f320cce25 --- /dev/null +++ b/packages/eslint-config/src/types.ts @@ -0,0 +1,67 @@ +export interface OptionsComponentExts { + /** + * Additional extensions for components. + * + * @example ['vue'] + * @default [] + */ + componentExts?: string[] +} + +export interface OptionsTypeScriptWithLanguageServer { + tsconfigPath: string + tsconfigRootDir?: string +} + +export interface OptionsConfig { + /** + * Enable TypeScript support. + * + * Passing an object to enable TypeScript Language Server support. + * + * @default auto-detect based on the dependencies + */ + typescript?: boolean | OptionsTypeScriptWithLanguageServer + + /** + * Enable test support. + * + * @default true + */ + test?: boolean + + /** + * Enable Vue support. + * + * @default auto-detect based on the dependencies + */ + vue?: boolean + + /** + * Enable JSONC support. + * + * @default true + */ + jsonc?: boolean + + /** + * Enable YAML support. + * + * @default true + */ + yaml?: boolean + + /** + * Enable Markdown support. + * + * @default true + */ + markdown?: boolean + + /** + * Enable stylistic rules. + * + * @default true + */ + stylistic?: boolean +}