UNPKG

@shayanthenerd/eslint-config

Version:

A modern, flexible ESLint configuration for enforcing best practices and maintaining a consistent coding style

236 lines 8.44 kB
import { PluginRules, RuleOptions } from "../eslintRules.mjs"; import { ConfigWithOverrides } from "../index.mjs"; //#region src/types/options/vue.d.ts type AnchorHasContentRuleOptions = RuleOptions<'vuejs-accessibility/anchor-has-content'>; interface BlockLang { style?: 'css' | 'scss' | 'postcss' | 'implicit'; script?: 'js' | 'ts' | 'jsx' | 'tsx' | 'implicit'; } type Macro = 'definePage' | 'defineEmits' | 'defineModel' | 'defineProps' | 'defineSlots' | 'defineCustom' | 'defineExpose' | 'defineOptions'; type SFCBlock = 'docs' | 'template' | 'script[setup]' | 'style[scoped]' | 'i18n[locale=en]' | 'script:not([setup])' | 'style:not([scoped])' | 'i18n:not([locale=en])'; type VBindStyleSameNameShorthandOptions = RuleOptions<'vue/v-bind-style', 1>['sameNameShorthand']; type ConfigRules = PluginRules<'vue'> & PluginRules<'vuejs-accessibility'>; interface VueOptions extends ConfigWithOverrides<ConfigRules> { /** * Use [eslint-plugin-vuejs-accessibility](https://vue-a11y.github.io/eslint-plugin-vuejs-accessibility) to enforce accessibility standards in SFCs. * * @default true */ accessibility?: boolean | { /** * Names of components that should be considered accessible child elements. * * New items extend the defaults instead of overriding them. * * @default ['img', 'picture', 'NuxtImg', 'NuxtPicture', 'UBadge'] * * @see [vuejs-accessibility/anchor-has-content: `accessibleChildren` option](https://vue-a11y.github.io/eslint-plugin-vuejs-accessibility/rules/anchor-has-content#%F0%9F%94%A7-options) */ accessibleChildComponents?: AnchorHasContentRuleOptions['accessibleChildren']; /** * Names of components that render an `<a>` element. * * New items extend the defaults instead of overriding them. * * @default ['RouterLink', 'NuxtLink', 'ULink'] * * @see [vuejs-accessibility/anchor-has-content: `components` option](https://vue-a11y.github.io/eslint-plugin-vuejs-accessibility/rules/anchor-has-content#%F0%9F%94%A7-options) */ anchorComponents?: AnchorHasContentRuleOptions['components']; /** * Names of components that render an `<img>` element. * * New items extend the defaults instead of overriding them. * * @default ['NuxtImg'] * * @see [vuejs-accessibility/alt-text: `img` option](https://vue-a11y.github.io/eslint-plugin-vuejs-accessibility/rules/alt-text#%F0%9F%94%A7-options) */ imageComponents?: RuleOptions<'vuejs-accessibility/alt-text'>['img']; }; /** * Enforce the use of specific attributes such as `scoped` and `module` on top-level `<style>` blocks. * * @default ['scoped', 'module'] * * @see [vue/enforce-style-attribute: `allow` option](https://eslint.vuejs.org/rules/enforce-style-attribute#options) */ allowedStyleAttributes?: RuleOptions<'vue/enforce-style-attribute'>['allow']; /** * Whether attributes should be hyphenated. * * @default 'never' * * @see [vue/attribute-hyphenation](https://eslint.vuejs.org/rules/attribute-hyphenation) */ attributeHyphenation?: RuleOptions<'vue/attribute-hyphenation'>; /** * The order of HTML and Vue attributes. * * @default * [ * 'CONDITIONALS', * 'RENDER_MODIFIERS', * 'LIST_RENDERING', * 'UNIQUE', * 'DEFINITION', * 'GLOBAL', * 'TWO_WAY_BINDING', * 'SLOT', * 'CONTENT', * 'OTHER_DIRECTIVES', * 'EVENTS', * 'ATTR_SHORTHAND_BOOL', * 'ATTR_DYNAMIC', * 'ATTR_STATIC', * ] * * @see [vue/attributes-order](https://eslint.vuejs.org/rules/attributes-order) */ attributesOrder?: RuleOptions<'vue/attributes-order'>['order']; /** * The language for top-lever SFC blocks. * * Use `implicit` to omit the `lang` attribute, which defaults to `css` for `<style>`, and `js` for `<script>`. * * @default * { * script: 'js', // `'ts'` if TypeScript integration is enabled * style: 'implicit', * } * * @see [vue/block-lang](https://eslint.vuejs.org/rules/block-lang) */ blockLang?: BlockLang; /** * The order of top-level blocks in SFCs. * * @default * [ * 'script:not([setup])', * 'script[setup]', * 'template', * 'i18n[locale=en]', * 'i18n:not([locale=en])', * 'style:not([scoped])', * 'style[scoped]', * 'docs', * ] * * @see [vue/block-order](https://eslint.vuejs.org/rules/block-order) */ blocksOrder?: SFCBlock[]; /** * Enforce consistent casing for component names in `<template>` blocks. * * Compound components (e.g., `<motion.div>`) are ignored by default. * * @default 'PascalCase' * * @see [vue/component-name-in-template-casing](https://eslint.vuejs.org/rules/component-name-in-template-casing) */ componentNameCaseInTemplate?: RuleOptions<'vue/component-name-in-template-casing'>; /** * Enforce a consistent style for destructuring props. * * @default 'only-when-assigned' * * @see [vue/define-props-destructuring: `destructure` option](https://eslint.vuejs.org/rules/define-props-destructuring#options) */ destructureProps?: RuleOptions<'vue/define-props-destructuring'>['destructure']; /** * Regex patterns of undefined component names that should be ignored. * * This is useful for ignoring components that are globally registered or defined in a way that ESLint cannot detect. * * New items extend the defaults instead of overriding them. * * @default * [ * '^(Nuxt|U)', * '^(Icon|Html|Head|Title|Base|Meta|Link|Style|Body|NoScript)$', * ] * * @see [vue/no-undef-components](https://eslint.vuejs.org/rules/no-undef-components) */ ignoredUndefinedComponents?: string[]; /** * The order of compiler macros in `<script setup>`. * * @default * [ * 'definePage', * 'defineOptions', * 'defineModel', * 'defineProps', * 'defineEmits', * 'defineSlots', * 'defineCustom', * 'defineExpose', * ] * * @see [vue/define-macros-order](https://eslint.vuejs.org/rules/define-macros-order) */ macrosOrder?: Macro[]; /** * Enforce consistent use of the `v-bind` same-name shorthand style. * * @default 'always' * * @see [vue/v-bind-style: `sameNameShorthand` option](https://eslint.vuejs.org/rules/v-bind-style#options) */ preferVBindSameNameShorthand?: Exclude<VBindStyleSameNameShorthandOptions, 'ignore'>; /** * Require the shorthand form of the attribute when `v-bind`'s value is `true`. * * @default 'always' * * @see [vue/prefer-true-attribute-shorthand](https://eslint.vuejs.org/rules/prefer-true-attribute-shorthand) */ preferVBindTrueShorthand?: RuleOptions<'vue/prefer-true-attribute-shorthand'>; /** * Disallow certain elements and components. * * When NuxtUI or NuxtImage are enabled, certain HTML elements (e.g., `<img>`, `<a>`, `<form>`, `<input>`) are disallowed in favor of their alternative components. * * @default [] * * @see [vue/no-restricted-html-elements](https://eslint.vuejs.org/rules/no-restricted-html-elements) */ restrictedElements?: RuleOptions<'vue/no-restricted-html-elements'>[]; /** * Disallow certain static attributes. * * @default [] * * @see [vue/no-restricted-static-attribute](https://eslint.vuejs.org/rules/no-restricted-static-attribute) */ restrictedStaticAttributes?: RuleOptions<'vue/no-restricted-static-attribute'>[]; /** * Maximum line length for `<template>` blocks (including comments). * * @default 130 * * @see [vue/max-len: `template` option](https://eslint.vuejs.org/rules/max-len.html#options) */ templateMaxLineLength?: Exclude<RuleOptions<'vue/max-len'>, number>['template']; /** * The delimiter used in `v-for` directives. * * @default 'in' * * @see [vue/v-for-delimiter-style](https://eslint.vuejs.org/rules/v-for-delimiter-style) */ vForDelimiterStyle?: RuleOptions<'vue/v-for-delimiter-style'>; /* https://github.com/vuejs/eslint-plugin-vue/issues/2571 */ // /** // * Enforce a consistent handler style in `v-on` directives. // * // * @default ['method', 'inline-function'] // * // * @see [vue/v-on-handler-style](https://eslint.vuejs.org/rules/v-on-handler-style) // */ // vOnHandlerStyle?: RuleOptions<'vue/v-on-handler-style'>, } //#endregion export type { VueOptions };