Tag Archives: Eslint

Error reporting of console.log in eslint

Error reporting of console.log in eslint

Due to the standardization of eslint, the use of console.log will also report errors. The following settings allow console.log console output

Description: open the package.json file, find the rules attribute, and add the following code

//The rule attribute is available by default. If not, add it to the eslintconfig attribute
“rules”: {
// this line of code allows console.log to set
“no console”: “off”
}

How to Solve Eslint syntax error in Vue project

“And” in the project; Errors are often reported. It’s really tangled. Today I see a solution that can be deleted without uninstallation

In the project root directory, create a new. Pretierrc file to remove semicolons and replace with single quotes

{
   "semi": false,
   "singleQuote": true
}

In this way, the format will not change to “”

You can also disable the syntax rules and modify the. Eslintrc.js file to disable the error items

module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/essential',
    '@vue/standard'
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ?'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ?'error' : 'off',
    'space-before-function-paren': 0 //Disable this rule
  },
  parserOptions: {
    parser: 'babel-eslint'
  }
}

 

[Solved] ESLint Error: Line 10 exceeds the maximum line length of 100

In the Vue cli component, there is a long text in the HTML encoding, and eslint reports an error: line 10 exceeds the maximum line length of 100 . Eslint sets that a line encoding cannot exceed 100 characters at most

Scheme 1:

Solution:

In the folder, there is a JS file. Eslintrc. JS to set eslint syntax, and set “Max len”: [“error”, {Code: 300}], as shown in the following figure

In the file, rules is the configured eslint syntax detection rule

You can set the encoding amount of a line according to your own needs.

Scheme 2:

the ESLIt syntax specification is ignored by setting ESLIt disable, and finally the omission is ended by setting ESLIt enable

Solution to the error of eslint “extra semicolon”

With multi-dimensional model as the core, let the factory digital transformation and upgrading “within reach”>>>

How to make money from mobile phones?I recommend a mobile app summary platform: finger music( http://www.szhile.com/ )You can earn hundreds of yuan a day by moving your fingers in your spare time

for projects built with Vue cli, the template is webpack, the default eslint configuration is based on standard, and the requirement is not to use semicolon

if we want to use a semicolon, add a configuration in the rules field:

'semi': ["error", "always"]


in this way, every expression in your JS code should end with a semicolon, otherwise eslint will give an error prompt

if you want eslint not to check the semicolon, the semicolon at the end of this time can be added or not. Configure in the rules field: if you want eslint not to check the semicolon, you can add it or not

'semi': 0

No undef check error in eslint

With multi-dimensional model as the core, let the factory digital transformation and upgrading “within reach”>>>

Error report when checking with eslint after writing code

error  'window' is not defined        no-undef

This is configured in eslint to check whether global variables are available. For specific use and description, please refer to http://eslint.org/docs/rules/no-undef

But I still have to use the window object in my code. What should I do

You can add a global configuration in eslint to mark which global objects can be used

"globals":{
  "document": true,
  "localStorage": true,
  "window": true
}

Update it. In addition, you can configure it according to this document

http://eslint.org/docs/user-guide/configuring.html#specifying -environments

   "env": {
            "browser": true,
            "node": true
        }