Code Monkey home page Code Monkey logo

vscode-eslint's Introduction

VS Code ESLint extension

Build Status

Integrates ESLint into VS Code. If you are new to ESLint check the documentation.

The extension uses the ESLint library installed in the opened workspace folder. If the folder doesn't provide one the extension looks for a global install version. If you haven't installed ESLint either locally or globally do so by running npm install eslint in the workspace folder for a local install or npm install -g eslint for a global install.

On new folders you might also need to create an .eslintrc configuration file. You can do this by either using the VS Code command Create ESLint configuration or by running the eslint command in a terminal with npx eslint --init.

Index

Release Notes

This section describes major releases and their improvements. For a detailed list of changes please refer to the change log.

From version 2.2.3 on forward odd minor or patch version numbers indicate an insider or pre-release. So versions 2.2.3, 2.2.5 and 2.3.1 will all be pre-release versions. 2.2.10, 2.4.10 and 3.0.0 will all be regular release versions.

Version 3.0.5 - pre-release

  • Support for the new ESLint flat config files has improved. The following changes have been implemented:
    • To use flat config files it is recommended to use ESLint version 8.57.0 or above.
    • There is a new eslint.useFlatConfig setting which is honored by ESLint version 8.57.0 and above. If one of those versions is used, the extension adheres to the ESLint Flat config rollout plan. The setting has the same meaning as the environment variable ESLINT_USE_FLAT_CONFIG.
    • The experimental settings eslint.experimental.useFlatConfig is deprecated and should only be used for ESLint versions >= 8.21 < 8.57.0.
  • Converted the server to use diagnostic pull instead of push.
  • Files will be revalidated on focus gain.
  • Add a command ESLint: Revalidate all open files to revalidate all open files.
  • Probing support for Astro, MDX and JSON
  • Various bug fixes

Version 2.4.4

  • same as 2.4.3 - pre-release

Version 2.4.3 - pre-release

Version 2.4.2

  • same as 2.4.1 pre-release.

Version 2.4.1 - Pre-release

Version 2.4.0 (same as 2.3.5 - Pre-release)

  • added settings options to control the time budget for validation and fix on save before a warning or error is raised. The settings are eslint.timeBudget.onValidation and eslint.timeBudget.onFixes
  • make server untitled agnostic
  • the extension uses now VS Code's language status indicator
  • the language status indicator now informs about long linting or fix on save times.
  • the setting eslint.alwaysShowStatus got removed since the status is now shown as a language status indicator.
  • support for flat config files
  • support for single problem underline.
  • various bug fixes

Version 2.3.5 - Pre-release

  • added settings options to control the time budget for validation and fix on save before a warning or error is raised. The settings are eslint.timeBudget.onValidation and eslint.timeBudget.onFixes

Version 2.3.3 - Pre-release

  • make server untitled agnostic

Version 2.3.1 - Pre-release (internal only)

  • the extension uses now VS Code's language status indicator
  • the language status indicator now informs about long linting or fix on save times.
  • the setting eslint.alwaysShowStatus got removed since the status is now shown as a language status indicator.

Version 2.3.0 - Pre-release

  • support for flat config files
  • support for single problem underline.
  • various bug fixes

Version 2.2.6 (same as 2.2.5 Pre-release)

  • added support for validating single notebook document cells if the language is supported by ESLint
  • various bug fixes

Version 2.2.5 - Pre-release

  • added support for validating single notebook document cells if the language is supported by ESLint
  • various bug fixes

Version 2.2.0

Added support for ESLint V8.0 Beta. To stay backwards compatible with eslint settings the version still uses the CLIEngine if available. However users can force the use of the new ESLint API using the setting eslint.useESLintClass. Beware that the ESLint npm module changed how options are interpreted. It also changed the names of certain options. If you used eslint.options to pass special options to the ESLint npm module you might need to adapt the setting to the new form.

Version 2.1.22

Adapt VS Code's workspace trust model. As a consequence the custom dialog ESLint introduced in version 2.1.7 got removed. In addition the off value got added to the eslint rule customization support.

Version 2.1.20

Added support to customize the severity of eslint rules. See the new setting eslint.rules.customizations.

Version 2.1.18

Asking for confirmation of the eslint.nodePath value revealed a setup where that value is defined separately on a workspace folder level although a multi workspace folder setup is open (e.g. a code-workspace file). These setups need to define the eslint.nodePath value in the corresponding code-workspace file and the extension now warns the user about it. Below an example of such a code-workspace file

{
        "folders": [
                {
                        "path": "project-a"
                },
                {
                        "path": "project-b"
                }
        ],
        "settings": {
                "eslint.nodePath": "myCustomNodePath"
        }
}

Version 2.1.17

To follow VS Code's model to confirm workspace local settings that impact code execution the two settings eslint.runtime and eslint.nodePath now need user confirmation if defined locally in a workspace folder or a workspace file. Users using these settings in those local scopes will see a notification reminding them of the confirmation need.

The version also adds a command to restart the ESLint server.

Version 2.1.10

The approval flow to allow the execution of a ESLint library got reworked. Its initial experience is now as follows:

  • no modal dialog is shown when the ESLint extension tries to load an ESLint library for the first time and an approval is necessary. Instead the ESLint status bar item changes to ESLint status icon indicating that the execution is currently block.
  • if the active text editor content would be validated using ESLint, a problem at the top of the file is shown in addition.

The execution of the ESLint library can be denied or approved using the following gestures:

  • clicking on the status bar icon
  • using the quick fix for the corresponding ESLint problem
  • executing the command ESLint: Manage Library Execution from the command palette

All gestures will open the following dialog:

ESLint Dialog

The chosen action is then reflected in the ESLint status bar item in the following way:

  • Allow will prefix the status bar item with a check mark.
  • Allow Everywhere will prefix the status bar item with a double check mark.
  • Deny and Disable will prefix the status bar item with a blocked sign.

You can manage our decisions using the following commands:

  • ESLint: Manage Library Execution will reopen above dialog
  • ESLint: Reset Library Decisions lets you reset previous decisions who have made.

This release also addresses the vulnerability described in CVE-2021-27081.

Version 2.0.4

The 2.0.4 version of the extension contains the following major improvements:

  • Improved TypeScript detection - As soon as TypeScript is correctly configured inside ESLint, you no longer need additional configuration through VS Code's eslint.validate setting. The same is true for HTML and Vue.js files.
  • Glob working directory support - Projects that have a complex folder structure and need to customize the working directories via eslint.workingDirectories can now use glob patterns instead of listing every project folder. For example, { "pattern": "code-*" } will match all project folders starting with code-. In addition, the extension now changes the working directory by default. You can disable this feature with the new !cwd property.
  • Formatter support: ESLint can now be used as a formatter. To enable this feature use the eslint.format.enable setting.
  • Improved Auto Fix on Save - Auto Fix on Save is now part of VS Code's Code Action on Save infrastructure and computes all possible fixes in one round. It is customized via the editor.codeActionsOnSave setting. The setting supports the ESLint specific property source.fixAll.eslint. The extension also respects the generic property source.fixAll.

The setting below turns on Auto Fix for all providers including ESLint:

    "editor.codeActionsOnSave": {
        "source.fixAll": "explicit"
    }

In contrast, this configuration only turns it on for ESLint:

    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": "explicit"
    }

You can also selectively disable ESLint via:

    "editor.codeActionsOnSave": {
        "source.fixAll": "explicit",
        "source.fixAll.eslint": "never"
    }

Also note that there is a time budget of 750ms to run code actions on save which might not be enough for large JavaScript / TypeScript file. You can increase the time budget using the editor.codeActionsOnSaveTimeout setting.

The old eslint.autoFixOnSave setting is now deprecated and can safely be removed.

Settings Options

If you are using an ESLint extension version < 2.x then please refer to the settings options here.

This extension contributes the following variables to the settings:

  • eslint.enable: enable/disable ESLint for the workspace folder. Is enabled by default.

  • eslint.debug: enables ESLint's debug mode (same as --debug command line option). Please see the ESLint output channel for the debug output. This options is very helpful to track down configuration and installation problems with ESLint since it provides verbose information about how ESLint is validating a file.

  • eslint.lintTask.enable: whether the extension contributes a lint task to lint a whole workspace folder.

  • eslint.lintTask.options: Command line options applied when running the task for linting the whole workspace (https://eslint.org/docs/user-guide/command-line-interface). An example to point to a custom .eslintrc.json file and a custom .eslintignore is:

    {
      "eslint.lintTask.options": "-c C:/mydirectory/.eslintrc.json --ignore-path C:/mydirectory/.eslintignore ."
    }
  • The old eslint.packageManager setting is now deprecated and can safely be removed. This controlled the package manager to be used to resolve the ESLint library. This has only an influence if the ESLint library is resolved globally. Valid values are "npm" or "yarn" or "pnpm".

  • eslint.options: options to configure how ESLint is started using either the ESLint class API or the CLIEngine API. The extension uses the ESLint class API if ESLint version 8 or higher is used or if ESLint version 7 is used and the setting eslint.useESLintCLass is set to true. In all other cases the CLIEngine API is used. An example to point to a custom .eslintrc.json file using the new ESLint API is:

    {
      "eslint.options": { "overrideConfigFile": "C:/mydirectory/.eslintrc.json" }
    }

    An example to point to a custom .eslintrc.json file using the old CLIEngine API is:

    {
      "eslint.options": { "configFile": "C:/mydirectory/.eslintrc.json" }
    }
  • eslint.useESLintClass (@since 2.2.0) - whether to use the ESLint class API even if the CLIEngine API is present. The setting is only honor when using ESLint version 7.x.

  • eslint.run - run the linter onSave or onType, default is onType.

  • eslint.quiet - ignore warnings.

  • eslint.runtime - use this setting to set the path of the node runtime to run ESLint under. Use "node" if you want to use your default system version of node.

  • eslint.execArgv - use this setting to pass additional arguments to the node runtime like --max_old_space_size=4096

  • eslint.nodeEnv - use this setting if an ESLint plugin or configuration needs process.env.NODE_ENV to be defined.

  • eslint.nodePath - use this setting if an installed ESLint package can't be detected, for example /myGlobalNodePackages/node_modules.

  • eslint.probe - an array for language identifiers for which the ESLint extension should be activated and should try to validate the file. If validation fails for probed languages the extension says silent. Defaults to ["javascript", "javascriptreact", "typescript", "typescriptreact", "html", "vue", "markdown"].

  • eslint.validate - an array of language identifiers specifying the files for which validation is to be enforced. This is an old legacy setting and should in normal cases not be necessary anymore. Defaults to ["javascript", "javascriptreact"].

  • eslint.format.enable: enables ESLint as a formatter for validated files. Although you can also use the formatter on save using the setting editor.formatOnSave it is recommended to use the editor.codeActionsOnSave feature since it allows for better configurability.

  • eslint.workingDirectories - specifies how the working directories ESLint is using are computed. ESLint resolves configuration files (e.g. eslintrc, .eslintignore) relative to a working directory so it is important to configure this correctly. If executing ESLint in the terminal requires you to change the working directory in the terminal into a sub folder then it is usually necessary to tweak this setting. (see also ESLint class options#cwd). Please also keep in mind that the .eslintrc* file is resolved considering the parent directories whereas the .eslintignore file is only honored in the current working directory. The following values can be used:

    • [{ "mode": "location" }] (@since 2.0.0): instructs ESLint to uses the workspace folder location or the file location (if no workspace folder is open) as the working directory. This is the default and is the same strategy as used in older versions of the ESLint extension (1.9.x versions).
    • [{ "mode": "auto" }] (@since 2.0.0): instructs ESLint to infer a working directory based on the location of package.json, eslint.config.js, .eslintignore and .eslintrc* files. This might work in many cases but can lead to unexpected results as well.
    • string[]: an array of working directories to use. Consider the following directory layout:
      root/
        client/
          .eslintrc.json
          client.js
        server/
          .eslintignore
          .eslintrc.json
          server.js
      
      Then using the setting:
        "eslint.workingDirectories": [ "./client", "./server" ]
      will validate files inside the server directory with the server directory as the current eslint working directory. Same for files in the client directory. The ESLint extension will also change the process's working directory to the provided directories. If this is not wanted a literal with the !cwd property can be used (e.g. { "directory": "./client", "!cwd": true }). This will use the client directory as the ESLint working directory but will not change the process`s working directory.
    • [{ "pattern": glob pattern }] (@since 2.0.0): Allows to specify a pattern to detect the working directory. This is basically a short cut for listing every directory. If you have a mono repository with all your projects being below a packages folder you can use { "pattern": "./packages/*/" } to make all these folders working directories.
  • eslint.codeAction.disableRuleComment - object with properties:

    • enable - show disable lint rule in the quick fix menu. true by default.
    • location - choose to either add the eslint-disable comment on the separateLine or sameLine. separateLine is the default. Example:
      { "enable": true, "location": "sameLine" }
  • eslint.codeAction.showDocumentation - object with properties:

    • enable - show open lint rule documentation web page in the quick fix menu. true by default.
  • eslint.codeActionsOnSave.mode (@since 2.0.12) - controls which problems are fix when running code actions on save.

    • all: fixes all possible problems by revalidating the file's content. This executes the same code path as running eslint with the --fix option in the terminal and therefore can take some time. This is the default value.
    • problems: fixes only the currently known fixable problems as long as their textual edits are non-overlapping. This mode is a lot faster but very likely only fixes parts of the problems.

    Please note that if eslint.codeActionsOnSave.mode is set to problems, the eslint.codeActionsOnSave.rules is ignored.

  • eslint.codeActionsOnSave.rules (@since 2.2.0) - controls the rules which are taken into consideration during code action on save execution. If not specified all rules specified via the normal ESLint configuration mechanism are consider. An empty array results in no rules being considered. If the array contains more than one entry the order matters and the first match determines the rule's on / off state. This setting is only honored under the following cases:

    • eslint.codeActionsOnSave.mode has a different value than problems
    • the ESLint version used is either version 8 or higher or the version is 7.x and the setting eslint.useESLintClass is set to true (version >= 8 || (version == 7.x && eslint.useESLintClass)).

    In this example only semicolon related rules are considered:

    "eslint.codeActionsOnSave.rules": [
      "*semi*"
    ]

    This example removes all TypeScript ESLint specific rules from the code action on save pass but keeps all other rules:

    "eslint.codeActionsOnSave.rules": [
      "!@typescript-eslint/*",
      "*"
    ]

    This example keeps the indent and semi rule from TypeScript ESLint, disables all other TypeScript ESLint rules and keeps the rest:

    "eslint.codeActionsOnSave.rules": [
        "@typescript-eslint/semi",
        "@typescript-eslint/indent",
        "!@typescript-eslint/*",
        "*"
    ]
  • eslint.rules.customizations (@since 2.1.20) - force rules to report a different severity within VS Code compared to the project's true ESLint configuration. Contains two properties:

    • "rule": Select on rules with names that match, factoring in asterisks as wildcards: { "rule": "no-*", "severity": "warn" }
      • Prefix the name with a "!" to target all rules that don't match the name: { "rule": "!no-*", "severity": "info" }
    • "severity": Sets a new severity for matched rule(s), "downgrade"s them to a lower severity, "upgrade"s them to a higher severity, or "default"s them to their original severity

    In this example, all rules are overridden to warnings:

    "eslint.rules.customizations": [
      { "rule": "*", "severity": "warn" }
    ]

    In this example, no- rules are informative, other rules are downgraded, and "radix" is reset to default:

    "eslint.rules.customizations": [
      { "rule": "no-*", "severity": "info" },
      { "rule": "!no-*", "severity": "downgrade" },
      { "rule": "radix", "severity": "default" }
    ]
  • eslint.format.enable (@since 2.0.0) - uses ESlint as a formatter for files that are validated by ESLint. If enabled please ensure to disable other formatters if you want to make this the default. A good way to do so is to add the following setting "[javascript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" } for JavaScript. For TypeScript you need to add "[typescript]": { "editor.defaultFormatter": "dbaeumer.vscode-eslint" }.

  • eslint.onIgnoredFiles (@since 2.0.10): used to control whether warnings should be generated when trying to lint ignored files. Default is off. Can be set to warn.

  • editor.codeActionsOnSave (@since 2.0.0): this setting now supports an entry source.fixAll.eslint. If set to true all auto-fixable ESLint errors from all plugins will be fixed on save. You can also selectively enable and disabled specific languages using VS Code's language scoped settings. To disable codeActionsOnSave for HTML files use the following setting:

    "[html]": {
      "editor.codeActionsOnSave": {
        "source.fixAll.eslint": false
      }
    }

    The old eslint.autoFixOnSave setting is now deprecated and can safely be removed. Please also note that if you use ESLint as your default formatter you should turn off editor.formatOnSave when you have turned on editor.codeActionsOnSave. Otherwise you file gets fixed twice which in unnecessary.

  • eslint.problems.shortenToSingleLine: (@since 2.3.0) - Shortens the text spans of underlined problems to their first related line.

  • eslint.experimental.useFlatConfig: (@since 2.3.0) - Enables support of experimental Flat Config (aka eslint.config.js, supported by ESLint version 8.21 or later)

  • eslint.timeBudget.onValidation (@since 2.3.5) - controls the time budget that can be used for validation before a warning or an error is shown.

  • eslint.timeBudget.onFixes (@since 2.3.5) - controls the time budget that can be used to compute fixes before a warning or an error is shown.

Settings Migration

If the old eslint.autoFixOnSave option is set to true ESLint will prompt to convert it to the new editor.codeActionsOnSave format. If you want to avoid the migration you can respond in the dialog in the following ways:

  • Not now: the setting will not be migrated by ESLint prompts again the next time you open the workspace
  • Never migrate Settings: the settings migration will be disabled by changing the user setting eslint.migration.2_x to off

The migration can always be triggered manually using the command ESLint: Migrate Settings

Commands:

This extension contributes the following commands to the Command palette.

  • Create '.eslintrc.json' file: creates a new .eslintrc.json file.
  • Fix all auto-fixable problems: applies ESLint auto-fix resolutions to all fixable problems.

Using the extension with VS Code's task running

The extension is linting an individual file only on typing. If you want to lint the whole workspace set eslint.lintTask.enable to true and the extension will also contribute the eslint: lint whole folder task. There is no need any more to define a custom task in tasks.json.

Using ESLint to validate TypeScript files

A great introduction on how to lint TypeScript using ESlint can be found in the TypeScript - ESLint. Please make yourself familiar with the introduction before using the VS Code ESLint extension in a TypeScript setup. Especially make sure that you can validate TypeScript files successfully in a terminal using the eslint command.

This project itself uses ESLint to validate its TypeScript files. So it can be used as a blueprint to get started.

To avoid validation from any TSLint installation disable TSLint using "tslint.enable": false.

Mono repository setup

As with JavaScript validating TypeScript in a mono repository requires that you tell the VS Code ESLint extension what the current working directories are. Use the eslint.workingDirectories setting to do so. For this repository the working directory setup looks as follows:

	"eslint.workingDirectories": [ "./client", "./server" ]

ESLint 6.x

Migrating from ESLint 5.x to ESLint 6.x might need some adaption (see the ESLint Migration Guide for details). Before filing an issue against the VS Code ESLint extension please ensure that you can successfully validate your files in a terminal using the eslint command.

vscode-eslint's People

Contributors

bpasero avatar chenxsan avatar darkred avatar dbaeumer avatar dependabot[bot] avatar edupsousa avatar eltociear avatar hirse avatar jogo- avatar joshuakgoldberg avatar joshunger avatar karlhorky avatar kaykayehnn avatar loune avatar lszomoru avatar mariasolos avatar mattlubner avatar mcmar avatar mossop avatar msftgits avatar mskelton avatar mysticatea avatar nguyenkhois avatar nikhilverma avatar notwearingpants avatar ota-meshi avatar paulirish avatar remcohaszing avatar scharf avatar torn4dom4n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-eslint's Issues

Some custom options being ignored

In my settings.json I have:

"eslint.options": {
"envs": ["es6", "node"],
"indent": [2, 2],
"curly": [2, "multi"]
}

The envs option is considered but not the rest.
If I place a comment within the file like

/* eslint indent: [2, 2] */

the option does get considered in the file.

EDIT: Nevermind. Found out in eslint docs that rules must me placed inside a property "rules".

"Failed to load eslint library" when installed

Currently getting the error message: "Failed to load eslint library. Please install eslint in your workspace folder using 'npm install eslint' or globally using 'npm install -g eslint' and then press Retry."

I'm currently using:
Code Version 0.10.6 (0.10.6),
eslint extension 0.10.11,
Node version 4.2.6
eslint version 1.10.3

I've installed eslint globally and can even run it via gulp. The plugin was working for me up until recently, no clue as to what exactly changed.

Eslint running on code outside of project scope

VSCode is showing 'duplicate identifier' errors for @return in this code:

/**
 * Determines the best possible implementation to run a function as soon as
 * the JS event loop is idle.
 * @return {function(function())} The "setImmediate" implementation.
 * @private
 */
goog.async.nextTick.getSetImmediateEmulator_ = function() {

Although this code is executed by my project, it lies well outside my workspace -- it is part of node's globally-installed (npm -g) packages.

If I close and re-open VSC, I do not see the errors, and cannot yet reproduce them.

Failed to load eslint library. Please install eslint in your workspace folder using 'npm install eslint' or globally using 'npm install -g eslint' and then pres

From @Ciget on February 10, 2016 21:56

Hi folks,

I several time during using VS Code see error like this:

Failed to load eslint library. Please install eslint in your workspace folder using 'npm install eslint' or globally using 'npm install -g eslint' and then pres

Of course i`ve tried to install it locally and globally as well, but no result - still the same error.
My OS - Windows 10. Version of VS Code - 0.10.8

Does somebody has the same issue and maybe you have thoughts how to fix it?
Thanks.

Copied from original issue: microsoft/vscode#2909

Eslint not working for version 0.22.1

Just noticed my eslint rules in .eslintrc are not being recognized when using eslint version 0.22.1. Worked fine when I upgraded to 1.9.0. Any ideas what might cause this?

ESlint extension should be used without npm modules

As vscode is gonna deprecate its internal validator, it's inconvenient to implement eslint-extension with downloading eslint(npm modules) every time and in every project folder.

I'd recommend vscode-eslint to be more easier to use by embed completely with the latest build of eslint or providing a way to config eslint-options globally in user-settings rather than creating an .eslint repeatedly.

How do I get this plugin to work?

I have gone through the (scant) documentation like ten times, but I still fail to understand how I am supposed to get this plugin to work.

Other editors like Sublime and Atom just work when they find an .eslintrc file in a parent of my current folder in the workspace, and pickup the eslint and babel-eslint packages from the workspace's node_modules folder.

With vscode, I'm completely bamboozled as to what I have to do.

From what I can understand in the fragmented documentations, I added a jsconfig.json file in my workspace. I also tried to add the eslintrc rules directly into the my Workspace settings in the eslint.options object.

And still, when I write bad code, this is what I get:

(options.globals || []).reduce is not a function

How can I figure what is going wrong from that? Where is this error coming from? Is there a guide anywhere which lays down what all exact steps have to be taken to get this working?

static properties in ES6 classes are being marked as errors

This is the error I'm getting on hovering over any class properties declared with static, even when the eslintrc has already defined es6 support. eslint CLI itself never gives this error.

'property declarations' can only be used in a .ts file.
(property) onChange: any

vscode-eslint-bug

Inline disable/enable rules

ESLint project configuration was picked up perfectly.

Problem: /* eslint-disable-no-console */ and /* eslint-enable-no-console */ are ignored.

Sorry, I don't know if this works with other rules.

Error message in VS Code "Configuration for rule "no-alert" is invalid"

I am not sure if this is the right place for the error. I am using VS Code 0.10.12-insider on MacOSX 10.11.3. Eslint is v2.4.0.

When opening an js file i get the error message in VS Code.

my-project/node_modules/eslint/conf/eslint.json: Configuration for rule "no-alert" is invalid: Severity should be one of the following: 0 = off, 1 = warning, 2 = error (you passed "off"). Referenced from: my-project/.eslintrc

Here is my . eslintrc file.

{
    "extends": "eslint:recommended",
    "env": {
        "node": true,
        "browser": true
    },
    "rules": {
        "accessor-pairs": 0,
        "no-array-constructor": 2,
        "block-scoped-var": 2,
        "brace-style": [2, "1tbs"],
        "camelcase": 0,
        "comma-dangle": [2, "never"],
        "comma-style": 2,
        "consistent-return": 0,
        "consistent-this": [2, "self"],
        "default-case": 2,
        "dot-notation": 2,
        "eol-last": 0,
        "func-style": [2, "declaration"],
        "guard-for-in": 2,
        "handle-callback-err": 1,
        "no-catch-shadow": 2,
        "no-cond-assign": 2,
        "no-console": 0,
        "no-constant-condition": 2,
        "no-control-regex": 2,
        "no-debugger": 2,
        "no-delete-var": 2,
        "no-div-regex": 2,
        "no-dupe-args": 2,
        "no-dupe-keys": 2,
        "no-duplicate-case": 2,
        "no-else-return": 2,
        "no-empty-character-class": 2,
        "no-eq-null": 2,
        "no-ex-assign": 2,
        "no-extra-boolean-cast": 2,
        "no-extra-parens": 2,
        "no-extra-semi": 2,
        "no-fallthrough": 2,
        "no-floating-decimal": 2,
        "no-func-assign": 2,
        "no-implicit-coercion": 1,
        "no-inner-declarations": 2,
        "no-invalid-regexp": 2,
        "no-invalid-this": 1,
        "no-irregular-whitespace": 2,
        "no-lonely-if": 2,
        "no-mixed-requires": [2, true],
        "no-mixed-spaces-and-tabs": 2,
        "no-negated-in-lhs": 2,
        "no-nested-ternary": 1,
        "no-new-require": 2,
        "no-obj-calls": 2,
        "no-octal": 2,
        "no-path-concat": 2,
        "no-redeclare": 2,
        "no-regex-spaces": 2,
        "no-self-compare": 2,
        "no-shadow": 1,
        "no-sparse-arrays": 2,
        "no-throw-literal": 2,
        "no-trailing-spaces": 2,
        "no-underscore-dangle": 0,
        "no-undef": 2,
        "no-undefined": 0,
        "no-unexpected-multiline": 2,
        "no-unneeded-ternary": 2,
        "no-unreachable": 2,
        "no-unused-vars": 2,
        "no-useless-call": 2,
        "no-void": 2,
        "quote-props": [2, "as-needed"],
        "quotes": [2, "single"],
        "radix": 2,
        "keyword-spacing": [2],
        "space-unary-ops": [2, { "words": true, "nonwords": false }],
        "semi": [2, "always"],
        "use-isnan": 2,
        "valid-jsdoc": [0, {
            "requireReturn": false
        }],
        "valid-typeof": 2,
        "wrap-iife": 2
    },
    "globals": {
        "afterEach": false,
        "angular": false,
        "beforeEach": false,
        "browser": false,
        "by": false,
        "element": false,
        "expect": false,
        "describe": false,
        "FileList": false,
        "inject": false,
        "it": false,
        "jasmine": false,
        "lxHelpers": false,
        "spyOn": false,
        "UAParser": false,
        "xdescribe": false,
        "xit": false
    }
}

As you can see i have no rule "no-alert" configured. But it checks my-project/node_modules/eslint/conf/eslint.json, where all rules are "off".

The check if rules are correct was introduced in eslint v2.4.0 (eslint/eslint#5527)

EPERM: operation not permitted, write

Clean install of VSCode, Eslint, vscode-eslint and I'm constantly receiving this in DevTools

EPERM: operation not permitted, write
e.doShow @ workbench.main.js:1598
e.show @ workbench.main.js:1598
e.showMessage @ workbench.main.js:1590
__dirname.undefined.t.Class.derive._oncancel @ workbench.main.js:1544
e.showMessage @ workbench.main.js:1590
e.handle @ workbench.main.js:1588
a @ workbench.main.js:1576
h.handle @ workbench.main.js:1576
(anonymous function) @ workbench.main.js:1602
(anonymous function) @ workbench.main.js:1602
emitTwo @ events.js:87
emit @ events.js:172
handleMessage @ internal/child_process.js:685
channel.onread @ internal/child_process.js:440

'globals' option is ignored

When I use the following configuration there's still a warning about missing chrome declaration:
"eslint.options": { "globals": [ "chrome" ] }

image

If there are ESLint in both global and local, please use local's

Currently, vscode-eslint seems to choose global installed ESLint if ESLint is installed in both global and local.
But local's should be more apposite version specified by package.json for the product.
So if there are ESLint in both local and global, I'd like to use local's.

When fixing error, ESLint issue is not updating

I had a LF expected but was CRLF. When I updated the file to be correct, the errors were not resolved. I had to close out VS Code and reopen to update the ESLint error reporter.

This was on Windows 10, version 0.10.5 of VS Code.

.eslintrc intellisense?

Hi @dbaeumer,

The shape of the .eslintrc is known - what would be involved in adding support for intellisense for the schema when editing a .eslintrc file.

The plugin do not clear Task reported errors

Currently vscode-eslint do not run lint through project, only on current file.

But I would like to know a list of all my errors through the project. So I defined a task to run eslint through the project.

Now I open an error and fixes it, but the marker is not cleared. I think as I've opened the file and modified something, vscode-eslint should be triggered and do something to clear up the marker.

Cannot find module 'eslint-config-airbnb' and/or 'eslint-plugin-react'

I've been trying to solve this for a couple of days and well... I wouldn't be asking if I fixed it ๐Ÿ˜„.

Cannot read config package: eslint-config-airbnb Error: Cannot find module 'eslint-config-airbnb' Referenced from: long_path.eslintrc

Cannot read config package: eslint-plugin-react Error: Cannot find module 'eslint-plugin-react' Referenced from: long_path.eslintrc

I deleted every package from global (except for webpack and webpack-dev-server).

I ran npm i eslint eslint-plugin-react eslint-config-airbnb babel-eslint -D and all of them appear in node_modules and package.json.

If I run node_modules\.bin\eslint file_name.jsx the command works just fine, using both the plugin and the config.

packages.json

"devDependencies": {
    "babel-core": "^6.6.5",
    "babel-eslint": "^5.0.0",
    "babel-loader": "^6.2.4",
    "babel-preset-es2015": "^6.6.0",
    "babel-preset-react": "^6.5.0",
    "chai": "^3.5.0",
    "chai-immutable": "^1.5.3",
    "eslint": "^2.3.0",
    "eslint-config-airbnb": "^6.1.0",
    "eslint-plugin-react": "^4.2.1",
    "file-loader": "^0.8.5",
    "jsdom": "^8.1.0",
    "mocha": "^2.4.5",
    "path": "^0.12.7",
    "react-hot-loader": "^1.3.0",
    "url-loader": "^0.5.7",
    "webpack": "^1.12.14",
    "webpack-dev-server": "^1.14.1"
  },

.eslintrc

"parser": "babel-eslint",
  "plugins": ["react"],
  "ecmaFeatures": {
    "jsx": true
  },
  "env": {
    "browser": true,
    "node": true
  },
  "extends": "airbnb",

Any tips on debugging this?

Error: Header must provide a Content-Length property

Hello, thank you for this great extension.

I began to receive error (in DevTools of vscode):

Error: Header must provide a Content-Length property.: Error: Header must provide a Content-Length property.
    at MessageReader.onData (C:\Users\elfer\.vscode\extensions\dbaeumer.vscode-eslint\node_modules\vscode-languageclient\node_modules\vscode-jsonrpc\lib\messageReader.js:105:27)
    at Socket.<anonymous> (C:\Users\elfer\.vscode\extensions\dbaeumer.vscode-eslint\node_modules\vscode-languageclient\node_modules\vscode-jsonrpc\lib\messageReader.js:92:19)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:110:10)
    at Pipe.onread (net.js:523:20)

First it works perfectly on my codebase. But at some moment (I didn't change eslint version or vscode version or extension (explicitly)) that error just appear and it is stable. I'm playing with eslint rules in .eslintrc.

If you need any additional info - let me know.

PS: sorry for my English

.eslintignore doesn't work

vscode is still analysing and reporting errors in ignored files in .eslintignore
and 'ignorePattern' config in .eslintrc.js

"Failed to load eslint library" not expected on project not using eslint

I uses eslint on one project so installed it locally along with this plugin.

When I open another project not using eslint I get this annoying error.

The error make no sense unless you install eslint globally. I always install all dependencies locally, not globally as that makes config easier to repro - just run npm install

[feature request] lint file with extension other than *.js

Currently the plugin only watch js files: documentSelector: ['javascript', 'javascriptreact'],

It would be nice if we can lint other file types, like *.html. eslint has many plugins that can support extracting javascript from other format, like html.

Atom's eslint plugin, has this option:

image

Error: Cannot read property 'type' of undefined

When I edit the constructor of a React component I get repeated errors of 'Cannot read property type of undefined' with every keystroke until I finish typing super(). Once I have the super() function in the constructor the errors stop.

The only two extensions I have installed are eslint and editorconfig. When I remove eslint the errors stop.

VS Code version: 0.10.11 f291f4ad600767626b24a4b15816b04bee9a3049
OS Version: OS X 10.11.3
ESLint version: 0.10.12

I've attached a small workspace that I'm able to reproduce the error in - just start typing anything into the constructor of the Tab.js file.

eslintTest.zip

The linter is not picking up project's eslintrc files

I have a folder structure like this:

| ParentProject
---| JSProject1
    ---| .eslintrc
---| JSProject2
    ---| .eslintrc
--- somefile.go
--- server.go

The parent project is golang, and has several child folders each being a ES6 project. Now, each project has it's own .eslintrc file, and a local installation of eslint in it's node_modules folder. VSCode doesn't seem to pick up the config files when I have opened a file in the child folders. This works flawlessly and very fast in Atom.

Use nearest package.json/node_modules to locate local eslint

My project consists of a web app with a package.json and a server side implemented in another language.

There's a top level dummy package.json for deployment reasons, and a package.json in webapp/, which is used for every (dev)dependency of the web app, including eslint.

The plugin works as expected when opening the webapp/ folder, but complains that I should install eslint in my workspace when opening the root project folder.

ESLint linter doesn't honor .eslintignore file

I would like to know how about how to use "eslint.options" ? I am really not having much luck with getting .eslintignore files to work.

I have tried placing it in the root directory, this doesn't appear to work.

I have tried adding the .eslintignore file using "eslint.options" :
"eslint.options": {
"ignorePath": ".eslintignore"
}

And also with an absolute path:
"eslint.options": {
"ignorePath": "/path/to/this/file/.eslintignore"
}

I have also tried adding the patterns with the "ignorePattern" option:
"eslint.options": {
"ignorePattern": "somefile.js"
}

All without luck! All on OS X.

I am making the assumption here that this is not a bug and rather its my miss-understanding of the implementation...

[feature request] mark errors in gutter

It would be good if the extension would mark the line at which errors occur along with JUST where it exactly occurs (this could just be a mark in the gutter at the line the error occurs).

This would make it easier to quickly scan through files.

Current:
screen shot 2016-02-24 at 3 33 41 pm

Suggested (taken from sublime):
screen shot 2016-02-24 at 3 33 32 pm

False Positive Errors on `linebreak-style` Rule

According to the eslint rule details for linebreak-style, the rule "linebreak-style": 2 should only throw an error if a file has inconsistent linebreaks in that file, but with my rule configured as such, this extension in VS Code complains:

Expected linebreaks to be 'LF' but found 'CRLF'. (linebreak-style)

on every line. If I run the eslint command in my cli, I get no errors. All my project files are uniformly CRLF which I verified with "linebreak-style": [2, "windows"] not returning any errors and "linebreak-style": [2, "unix"] throwing an error on every line.

Display "ESLint" and the triggered rule within the tooltip

Overall, I am very pleased with vscode-eslint. However, when ESLint inappropriately (from my point of view) flags some offending syntax, it is difficult to determine which rule caused the error.

Also, when several linters are active (including the built VS Code IntelliSense), I am not certain which is causing the text to be highlighted.

Would it be possible to format the tooltip along the lines of:

ESLint: you have done something stupid (stupid-syntax-rule)

The same format would be ideal if included in the VS Code error summary (ctrl-p + !).

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.