search

Home  >  Q&A  >  body text

javascript - vue-cli eslint configuration problem

It’s a big headache to use eslint. I don’t want to use it anymore.
Main problems
1. I want to write functions in underline and variables in camel case.
Currently I only use the configuration scheme I found the option camelcase, but it seems to change all naming, and I hope that functions, variables and even constants use different naming methods.

2. The files generated by vue-cli by default are indented with double spaces and do not add ";" to break sentences.
But I am used to using teb indentation and ";" to break sentences.
In this way, I can only use the default writing method Code words, otherwise the style will not be unified.

The meaning of this problem is that the page automatically generated by the scaffolding is a file with double spaces and no ; sign.
Using the customary writing method, tab/space indentation will appear, with ; sign and no; sign appearing at the same time. .This is very bad.
I have to have a unified style for each file. This workload is not small!

3. I am used to the abbreviation of var a, b, c = 0;, how to configure eslint?

4. How to turn off the eslint verification of a certain file individually?

巴扎黑巴扎黑2748 days ago512

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-05-18 11:00:05

    1, 2, 3 These problems are all eslint configuration problems. When eslint reports an error, find the corresponding rule, then add the corresponding rule in .eslintrc里面的rules, and then set the value to 0. Or at the beginning of a certain file Plus

    /* eslint no-console: 0 */

    For example, this rule will not report errors when using the console. 0 means ignoring the error, 1 means a warning with a green underline, and 2 means an error with a red underline. Corresponding to several lints in your question, I don’t remember the rules very clearly. You can check them and add them according to the above method.

    4. Create a new one in the root directory .eslintignore and add your file in it

    reply
    0
  • ringa_lee

    ringa_lee2017-05-18 11:00:05

    You can search and you will get the answer. You can read my article about how to get rid of the crazy ESlint syntax detection configuration instructions

    reply
    0
  • PHP中文网

    PHP中文网2017-05-18 11:00:05

    Some additions to the answer above:

    1. id-match barely meets your needs. If you really want to limit the rules, you can consider customizing the rules

    2. You can use eslint --fix. If you find it troublesome, you can refer to this article to add the eslint --fix shortcut key to the .vue file

    3. The corresponding rule is one-var

    4. Using the way @Zhishui said it

    reply
    0
  • Cancelreply