Disable a specific linter rule in Atom (for js-standard)

前端 未结 4 1809
悲&欢浪女
悲&欢浪女 2021-01-12 15:19

How do I tell an Atom linter, specifically js-standard, to ignore a rule? I want it ignored project-wide, and I thought that I could achieve this with a package.json or a .e

4条回答
  •  花落未央
    2021-01-12 16:17

    Using the default install, there is no way to do this in linter-js-standard. (I believe this was a conscious decision on the part of the module authors who believe that standard is a hard target rather than an ideal.)

    If you wish to use eslint-style comments to disable linting for certain lines or code sections, install babel-eslint via npm i --save-dev babel-eslint and add

    {
      ...
      "standard": {
        "parser": "babel-eslint"
      }
      ...
    }
    

    to your package.json file which will allow you to annotate your source as needed.

    Example

    Assuming foo is defined but not used elsewhere in your file, linter will warn: 'foo is assigned a value but never used. (no-unused-vars)'

    const foo = 1
    

    After installing babel-eslint, configuring standard in your package.json file, and adding this comment, linter will ignore the line.

    const foo = 1 // eslint-disable-line
    

    See Configuring ESLint for other configuration annotations.

提交回复
热议问题