vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.41k stars 659 forks source link

prop-name-casing does not default to error #810

Closed frankandrobot closed 4 years ago

frankandrobot commented 5 years ago

Tell us about your environment node 8.12.0 eslint 5.5.0 eslint-plugin-vue 5.1.0

Please show your full configuration: We have a global eslintrc, which is overridden in the Vue folder

module.exports = {
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    'shared-node-browser': true,
    mocha: true,
  },
  globals: {
    sinon: true,
    expect: true,
  },
  extends: [
    'eslint:recommended',
    'plugin:react/recommended',
    'prettier',
    // this global linting of Vue snippets
    'plugin:vue/recommended',
  ],
  parserOptions: {
    parser: 'babel-eslint',
    ecmaVersion: 2017,
    ecmaFeatures: {
      jsx: true,
    },
    sourceType: 'module',
  },
  plugins: ['mocha', 'react', 'connect', 'vue'],
  rules: {
    // manually-enabled rules

    'prefer-const': ['error'],

    eqeqeq: ['error', 'smart'],

    'semi-spacing': 'off',
    'valid-jsdoc': [
      'error',
      {
        requireReturn: false,
        requireParamDescription: false,
        requireReturnDescription: false,
      },
    ],
    'no-unneeded-ternary': 'error',
    'connect/reduce': 'error',
    'mocha/no-mocha-arrows': 'error',
    'react/no-multi-comp': [
      'error',
      {
        ignoreStateless: true,
      },
    ],
    'react/no-render-return-value': 'error',
    'react/prefer-es6-class': ['error', 'always'],
    'react/prefer-stateless-function': [
      'error',
      {
        ignorePureComponents: true,
      },
    ],
    'react/no-unknown-property': 'error',
    'no-var': 'error',

    // enabled by wizard

    'accessor-pairs': 'error',
    complexity: 'warn',
    'func-name-matching': 'error',
    'global-require': 'error',
    'handle-callback-err': 'error',
    'id-blacklist': 'error',
    'id-match': 'error',
    'linebreak-style': ['error', 'unix'],
    'lines-around-directive': 'error',
    'max-depth': 'error',
    'max-nested-callbacks': 'error',
    'no-alert': 'error',
    'no-array-constructor': 'error',
    'no-bitwise': 'error',
    'no-caller': 'error',
    'no-catch-shadow': 'error',
    'no-confusing-arrow': 'error',
    'no-continue': 'error',
    'no-div-regex': 'error',
    'no-empty': [
      'error',
      {
        allowEmptyCatch: true,
      },
    ],
    'no-eval': 'error',
    'no-extend-native': 'error',
    'no-extra-bind': 'error',
    'no-extra-label': 'error',
    'no-implicit-coercion': [
      'error',
      {
        boolean: false,
        number: false,
        string: false,
      },
    ],
    'no-implicit-globals': 'error',
    'no-implied-eval': 'error',
    'no-inner-declarations': ['error', 'functions'],
    'no-iterator': 'error',
    'no-label-var': 'error',
    'no-labels': 'error',
    'no-lone-blocks': 'error',
    'no-lonely-if': 'error',
    'no-loop-func': 'error',
    'no-mixed-requires': 'error',
    'no-multi-str': 'error',
    'no-native-reassign': 'error',
    'no-negated-in-lhs': 'error',
    'no-new': 'error',
    'no-new-func': 'error',
    'no-new-object': 'error',
    'no-new-require': 'error',
    'no-new-wrappers': 'error',
    'no-octal-escape': 'error',
    'no-path-concat': 'error',
    'no-process-exit': 'error',
    'no-proto': 'error',
    'no-restricted-globals': 'error',
    'no-restricted-imports': 'error',
    'no-restricted-modules': 'error',
    'no-restricted-properties': 'error',
    'no-restricted-syntax': 'error',
    'no-return-assign': 'error',
    'no-self-compare': 'error',
    'no-shadow-restricted-names': 'error',
    'no-sync': 'error',
    'no-template-curly-in-string': 'error',
    'no-undef-init': 'error',
    'no-unmodified-loop-condition': 'error',
    'no-useless-call': 'error',
    'no-useless-computed-key': 'error',
    'no-useless-concat': 'error',
    'no-useless-constructor': 'error',
    'no-useless-rename': 'error',
    'no-void': 'error',
    'no-with': 'error',
    'operator-assignment': ['error', 'always'],
    'prefer-numeric-literals': 'error',
    'prefer-spread': 'error',
    radix: 'error',
    strict: 'error',
    'symbol-description': 'error',
    yoda: ['error', 'never'],
    'no-shadow': [
      'error',
      {
        builtinGlobals: true,
        hoist: 'functions',
      },
    ],
    'array-callback-return': 'error',
    curly: 'error',

    // disabled rules

    'array-bracket-spacing': 'off',
    'arrow-body-style': 'off',
    'arrow-parens': 'off',
    'arrow-spacing': 'off',
    'block-scoped-var': 'off',
    'block-spacing': 'off',
    'callback-return': 'off',
    camelcase: 'off',
    'class-methods-use-this': 'off',
    'comma-spacing': 'off',
    'consistent-return': 'off',
    'consistent-this': 'off',
    'default-case': 'off',
    'dot-notation': 'off',
    'func-style': 'off',
    'guard-for-in': 'off',
    'id-length': 'off',
    indent: 'off',
    'init-declarations': 'off',
    'key-spacing': 'off',
    'keyword-spacing': 'off',
    'line-comment-position': 'off',
    'lines-around-comment': 'off',
    'max-lines': 'off',
    'max-params': 'off',
    'max-statements': 'off',
    'max-statements-per-line': 'off',
    'multiline-ternary': 'off',
    'new-parens': 'off',
    'newline-after-var': 'off',
    'newline-before-return': 'off',
    'newline-per-chained-call': 'off',
    'no-duplicate-imports': 'off',
    'no-else-return': 'off',
    'no-empty-function': 'off',
    'no-eq-null': 'off',
    'no-inline-comments': 'off',
    'no-invalid-this': 'off',
    'no-magic-numbers': 'off',
    'no-mixed-operators': 'off',
    'no-multi-spaces': 'off',
    'no-multiple-empty-lines': 'off',
    'no-negated-condition': 'off',
    'no-nested-ternary': 'off',
    'no-param-reassign': 'off',
    'no-plusplus': 'off',
    'no-process-env': 'off',
    'no-prototype-builtins': 'off',
    'no-script-url': 'off',
    'no-sequences': 'off',
    'no-tabs': 'off',
    'no-ternary': 'off',
    'no-throw-literal': 'off',
    'no-trailing-spaces': 'off',
    'no-undefined': 'off',
    'no-underscore-dangle': 'off',
    'no-unused-expressions': 'off',
    'no-use-before-define': 'off',
    'no-useless-escape': 'off',
    'no-useless-return': 'off',
    'no-warning-comments': 'off',
    'no-whitespace-before-property': 'off',
    'object-curly-newline': 'off',
    'object-curly-spacing': 'off',
    'object-property-newline': 'off',
    'object-shorthand': 'off',
    'one-var': 'off',
    'one-var-declaration-per-line': 'off',
    'operator-linebreak': 'off',
    'padded-blocks': 'off',
    'prefer-arrow-callback': 'off',
    'prefer-reflect': 'off',
    'prefer-rest-params': 'off',
    'prefer-template': 'off',
    'quote-props': 'off',
    'require-jsdoc': 'off',
    'sort-imports': 'off',
    'sort-keys': 'off',
    'sort-vars': 'off',
    'space-before-blocks': 'off',
    'space-before-function-paren': 'off',
    'space-in-parens': 'off',
    'space-infix-ops': 'off',
    'space-unary-ops': 'off',
    'spaced-comment': 'off',
    'vars-on-top': 'off',
    'wrap-iife': 'off',
    'wrap-regex': 'off',
  },
};

Vue-specific config file which overrides the one above

const base = require('../.eslintrc');

// remove react
base.extends = base.extends.filter(x => x !== 'plugin:react/recommended');
base.plugins = base.plugins.filter(x => x !== 'react');

// enable VUE file linting
base.plugins.push('vue');

module.exports = base;

What did you do?

<template>
  <div class="full-width center-content">
    <h1>Hello World!</h1>
  </div>
</template>

<style scoped>
.full-width {
  width: 100%;
}
.center-content {
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>

<script>
export default {
  props: {
    'name-foo': {
      type: String,
      required: true,
    },
  },
};
</script>

What did you expect to happen? I expect to get an error when I lint the above VUE file. As per the docs, it should be an error: https://github.com/vuejs/eslint-plugin-vue/blob/v5.1.0/docs/rules/prop-name-casing.md

What actually happened? I get a warning

> eslint --ext .js,.vue js src

/Users/uri/Documents/connect/dashboard/js/components/app-settings/access/access.controller.js
  81:42  warning  Arrow function has a complexity of 24  complexity

/Users/uri/Documents/connect/dashboard/js/components/content-list/content-list.reducers.js
  195:16  warning  Function 'contentList' has a complexity of 29  complexity

/Users/uri/Documents/connect/dashboard/js/components/form-validation/form-validation.directive.js
  138:9  warning  Function 'validUsername' has a complexity of 29  complexity

/Users/uri/Documents/connect/dashboard/src/Hello.vue
  21:5  warning  Prop "name-foo" is not in camelCase  vue/prop-name-casing

✖ 4 problems (0 errors, 4 warnings)
  0 errors and 1 warning potentially fixable with the `--fix` option.
ota-meshi commented 4 years ago

Thank you for this issue.

In the provided preset, vue/prop-name-casing rule is set to warning. If you want to make an error, add the following settings to rules.

  "vue/prop-name-casing": "error",