How to remove eslint verification for projects built by vue-cli scaffolding

Eslint verification has brought us great help in improving our code quality and good coding style, but due to its strict syntax verification, many programmers are very uncomfortable when they use it in the early stage, and they want to remove eslint verification. .

In fact, the method of removing eslint verification is not complicated, because our scaffolding is based on webpack, so the general configuration operations will be configured in the configuration file of the webpack tool, then we can directly find the configuration file of webpack. Maybe many of our friends who are new to the vue-cli scaffolding tool may say that after I build the project, there are 3 configuration files starting with webpack in the build directory, so which one should I look for?

We can look at the names of the files, which are: webpack.base.conf.js, webpack.dev.conf.js, webpack.prod.conf.js, so that we can easily determine webpack.dev.conf.js It is some configuration executed when running the development environment, webpack.prod.conf.js is some configuration when running the generation environment, and then webpack.base.conf.js is a basic configuration file, and the purpose we want to achieve is timely Whether it is the development environment or the production environment, the eslint verification is removed, so whether it is to modify the development environment or the production environment can not achieve our purpose, then the rest is to modify the webpack.base.conf.js or modify the production environment or the development environment respectively. configured. At this point, you basically know how to modify the basic configuration file webpack.base.conf.js without further thinking. The specific modification method is as follows:

  module: {
    rules: [
      ...(config.dev.useEslint ? [createLintingRule()] : []),
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },

Find this code first, and then delete or comment out the rules of eslint. Final code:

  module: {
    rules: [
     // ...(config.dev.useEslint ? [createLintingRule()] : []),
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: vueLoaderConfig
      },
I have written so much, in fact, I want to talk about how to deal with problems when we encounter them. If we can’t find a solution or way of thinking for a while, we can’t avoid using the elimination method, and then we need to analyze and think more. In this way, our coding level will also improve very quickly. Although the eslint syntax verification has been removed, we still have to maintain a good coding style. Our code can not only be understood by us at the time of coding, so that others can understand it, but also later people can understand it. Our technology and ideas are passed on.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325815347&siteId=291194637
Recommended