Skip to content

lint js files and reporting a non-existed formatting error #411

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

Closed
mrzzcn opened this issue Feb 26, 2018 · 2 comments
Closed

lint js files and reporting a non-existed formatting error #411

mrzzcn opened this issue Feb 26, 2018 · 2 comments

Comments

@mrzzcn
Copy link

mrzzcn commented Feb 26, 2018

Tell us about your environment

Please show your full configuration:

// https://eslint.org/docs/user-guide/configuring

module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint'
  },
  env: {
    browser: true,
  },
  // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
  // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
  extends: ['plugin:vue/essential', 'airbnb-base'],
  // required to lint *.vue files
  plugins: [
    'vue'
  ],
  // check if imports actually resolve
  settings: {
    'import/resolver': {
      webpack: {
        config: 'build/webpack.base.conf.js'
      }
    }
  },
  // add your custom rules here
  rules: {
    // don't require .vue extension when importing
    'import/extensions': ['error', 'always', {
      js: 'never',
      vue: 'never'
    }],
    indent: 'off',
    'vue/script-indent': ['error', 2, {
      'baseIndent': 1,
      'switchCase': 1,
      'ignores': []
    }],
    // disallow reassignment of function parameters
    // disallow parameter object manipulation except for specific exclusions
    'no-param-reassign': ['error', {
      props: true,
      ignorePropertyModificationsFor: [
        'state', // for vuex state
        'acc', // for reduce accumulators
        'e' // for e.returnvalue
      ]
    }],
    // allow optionalDependencies
    'import/no-extraneous-dependencies': ['error', {
      optionalDependencies: ['test/unit/index.js']
    }],
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
  }
}

What did you do? Please include the actual source code causing the issue.

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || document.title;
  next();
});

What did you expect to happen? only work for vue files?

What actually happened? Please include the actual, raw output from ESLint. working for js file and in a wrong way.

@michalsnik
Copy link
Member

michalsnik commented Mar 21, 2018

Hey @mrzzcn ! Thanks for posting this issue. I see two things here:

  1. Wrong indentation being reported
    I think this might've been resolved by Fix: wrong indentation (fixes #407) #413 which not yet released, will be today :)

  2. Your .vue files are not being linted.
    Eslint configuration is not a place where you point what files it should or should not lint. You have to point it explicitly, either while using command line, or in your build configuration. In command line it looks like this:

eslint . --ext .js,.vue

@michalsnik
Copy link
Member

I checked and with v4.4.0 indentation seems to be working fine.

If you however want this rule to only check vue files, and keep built-in indent rule for plain .js files you can override part of the configuration like this:

"rules": {
    "indent": ["error", 2]
},
"overrides": [
    {
      "files": ["*.vue"],
      "rules": {
        "indent": "off",
        "vue/script-indent": ["error", 2, { "baseIndent": 1 }]
      }
    }
  ]

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

No branches or pull requests

2 participants