Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue/prop-name-casing - ignoreProps not working #2691

Open
2 tasks done
DonRedwoood opened this issue Feb 22, 2025 · 1 comment
Open
2 tasks done

vue/prop-name-casing - ignoreProps not working #2691

DonRedwoood opened this issue Feb 22, 2025 · 1 comment

Comments

@DonRedwoood
Copy link

DonRedwoood commented Feb 22, 2025

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 9.20.1
  • eslint-plugin-vue version: 9.32.0
  • Vue version: 3.5.13
  • Node version: 20.9.0
  • Operating System: Windows 11

Please show your full configuration:

// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginVue from 'eslint-plugin-vue';
import stylistic from '@stylistic/eslint-plugin';

export default tseslint.config(
  eslint.configs.recommended,
  tseslint.configs.recommended,
  pluginVue.configs['flat/recommended'],
  {
    files   : ['**/*.js', '**/*.ts', '**/*.vue'],
    ignores : ['**/vendor/*.js', '**/vendor/*.ts', 'vite.config.ts'],
    plugins : {
      'typescript-eslint' : tseslint.plugin,
      '@stylistic'        : stylistic,
    },
    languageOptions : {
      parserOptions : {
        parser              : tseslint.parser,
        project             : './tsconfig.json',
        projectService      : true,
        extraFileExtensions : ['.vue'],
        sourceType          : 'module',
      },
    },
  },
  {
    plugins : {
      '@stylistic' : stylistic,
    },
    rules : {
      '@stylistic/indent' : [
        'error',
        2,
        {
          'ignoredNodes' : [
            'Program > *',         // Ignore top-level indentation for <script> tags in Vue files
            'TemplateLiteral > *', // Ignore top-level indentation for <template> tags in Vue files
          ],
          'outerIIFEBody'      : 'off',
          'SwitchCase'         : 1,
          'VariableDeclarator' : {
            'const' : 1,
            'let'   : 1,
            'var'   : 1,
          }
        }
      ],
      '@typescript-eslint/no-empty-function'    : 'off',
      '@typescript-eslint/no-empty-object-type' : 'off',
      '@typescript-eslint/no-explicit-any'      : 'off',
      '@typescript-eslint/no-unused-vars'       : [
        'error',
        {
          'args'              : 'after-used',
          'argsIgnorePattern' : '^_',
        },
      ],
      '@typescript-eslint/no-var-requires' : 'off',
      'arrow-parens'                       : ['error', 'always'],
      'arrow-spacing'                      : 'error',
      'comma-dangle'                       : [
        'error',
        {
          'arrays'    : 'only-multiline',
          'exports'   : 'never',
          'functions' : 'never',
          'imports'   : 'never',
          'objects'   : 'only-multiline',
        }
      ],
      'key-spacing' : [
        2,
        {
          'afterColon'  : true,
          'align'       : 'colon',
          'beforeColon' : true,
          'mode'        : 'minimum',
        },
      ],
      'linebreak-style'              : ['error', 'unix'],
      'newline-after-var'            : 'off',
      'newline-before-return'        : 'off',
      'no-cond-assign'               : 'off',
      'no-console'                   : 'off',
      'no-const-assign'              : ['error'],
      'no-extra-semi'                : 'off',
      'no-prototype-builtins'        : 'off',
      'no-trailing-spaces'           : 'error',
      'no-undef'                     : 'off',
      'no-unused-vars'               : 'off',
      'no-var'                       : 'off',
      'one-var'                      : 'off',
      'one-var-declaration-per-line' : 'off',
      'quotes'                       : [
        'warn',
        'single',
        {
          'allowTemplateLiterals' : true,
        },
      ],
      'semi'                        : 'warn',
      'space-before-function-paren' : ['error', 'never'],
      'space-in-parens'             : ['error', 'never'],
      'space-unary-ops'             : [
        2,
        {
          'nonwords' : true,
          'words'    : true,
        },
      ],
      'vue/component-name-in-template-casing' : ['error','kebab-case'],
      'vue/component-options-name-casing'     : ['error', 'kebab-case'],
      'vue/html-closing-bracket-newline'      : [
        'error',
        {
          'multiline'  : 'never',
          'singleline' : 'never',
        },
      ],
      'vue/html-indent' : [
        'error',
        2,
        {
          'alignAttributesVertically' : true,
          'attribute'                 : 1,
          'baseIndent'                : 1,
          'closeBracket'              : 0,
          'ignores'                   : [],
        },
      ],
      'vue/multi-word-component-names'             : 'off',
      'vue/multiline-html-element-content-newline' : [
        'error',
        {
          'allowEmptyLines' : true,
          'ignores'         : [
            'a',
            'pre',
            'router-link',
            'span',
            'textarea',
          ],
        },
      ],
      'vue/prop-name-casing' : ['error', 'camelCase', {
        'ignoreProps' : ['aria-hidden'],
      }],
      'vue/no-unused-vars'       : 'off',
      'vue/require-default-prop' : 'off',
      'vue/require-prop-types'   : 'off',
      'vue/require-v-for-key'    : 'off',
    },
  },
  {
    files : ['**/*.vue'],
    rules : {
      indent : 'off',
    },
  }
);

What did you do?

      'vue/prop-name-casing' : ['error', 'camelCase', {
        'ignoreProps' : ['aria-hidden'],
      }],

What did you expect to happen?

The rule above breaks ESLint. I ideally want all props that start with aria- to be permitted but to simplify the issue I removed my regex attempt. The moment I add the the options object with 'ignoreProps' and restart ESLint, it stops working. With the { 'ignoreProps': '...' } options removed, it works again.

$ npx eslint .

Oops! Something went wrong! :(

ESLint: 9.20.1

Error: Key "rules": Key "vue/prop-name-casing":
        Value ["camelCase",{"ignoreProps":["aria-hidden"]}] should NOT have more than 1 items.
@DonRedwoood
Copy link
Author

I did some browsing of the eslint-plugin-vue codebase and it looks like the reason this isn't working is because it's a new feature, so what's listed in the official documentation hasn't actually made it to an official release yet. Naturally it's my luck to use a brand-new feature based on documentation. 🤦‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant