ESLINT
intelliJ install + error codes

Config ESLint + PluginsLinters and JetbrainsDebug Javascript in ChromeRules + Error Codes

https://clickety-clack.click/img/eslint.html

ESLintUltimate

Last modified: 20 April 2021

IntelliJ IDEA integrates with ESLint which brings a wide range of linting rules that can also be extended with plugins. IntelliJ IDEA shows warnings and errors reported by ESLint right in the editor, as you type. With ESLint, you can also use JavaScript Standard Style as well as lint your TypeScript code.

Besides JavaScript and TypeScript, ESLint can be applied to files of other types in the entire project or in its specific parts, see Configure linting scope.

Before you start

  1. Download and install Node.js.

  2. Make sure a local Node.js interpreter is configured in your project: open the Settings/Preferences dialog ⌘, and go to Languages and Frameworks | Node.js and NPM. The Node Interpreter field shows the default project Node.js interpreter.

    Learn more from Configuring a local Node.js interpreter.

Install ESLint

  1. In the embedded Terminal (⌥F12), type one of the following commands:

    • npm install --g eslint for global installation.
    • npm install --save-dev eslint to install ESLint as a development dependency.
  2. Optionally, install additional plugins, for example, eslint-plugin-react to lint React applications.

 

 

 

 

Activate and configure ESLint in IntelliJ IDEA

By default, ESLint is disabled. You can choose to configure it automatically or specify all the configuration settings manually.

Configure ESLint automatically

With automatic configuration, IntelliJ IDEA uses the ESLint package from the project node_modules folder and the .eslintrc.* configuration file from the folder where the current file is stored. If no .eslintrc.* is found in the current file folder, IntelliJ IDEA will look for one in its parent folders up to the project root.

If you have several package.json files with ESLint listed as a dependency, IntelliJ IDEA starts a separate process for each package.json and processes everything below it. This lets you apply a specific ESLint version or a specific set of plugins to each path in a monorepo or a project with multiple ESLint configurations.

  • To configure ESLint automatically in the current project, open the Settings/Preferences dialog ⌘,, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select the Automatic ESLint configuration option.
  • To configure ESLint automatically in all new projects, open the Settings for New Projects dialog (File | New Projects Settings | Settings for New Projects), go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select the Automatic ESLint configuration option.

Configure ESLint manually

With manual configuration, you can use a custom ESLint package, configuration file, and working directories, as well as apply various additional rules and options.

  1. In the Settings/Preferences dialog ⌘,, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select Manual ESLint configuration.

  2. In the ESLint package field, specify the location of the eslint or standard package.

  3. In the Working directories field, specify the working directories for the ESLint process.

    By default the field is empty and IntelliJ IDEA detects the working directory automatically. First it looks for a directory closest to the linted file which contains a .eslintignore or .eslintrc.* file, or a package.json file with either a eslintIgnore or a eslintConfig property.

    If the auto-detected working directory doesn't match your project configuration, you need to specify the working directory (directories) manually. Use semicolons as separators. The acceptable values are:

    • Absolute paths.

    • Paths relative to the project base directory (the parent folder of the .idea folder where IntelliJ IDEA-specific project metadata is stored). For example:

      • ./– use project base directory as ESLint process working directory.
      • client;server– use the <project_base_dir>/client and <project_base_dir>/server as working directories. For files that are neither under the client not under the server folder, the working directory will be auto-detected as described above.
      • packages/*– each subfolder of the <project_base_dir>/packages folder will be used as the working directory for the corresponding linted files.
    • Paths relative to the content roots can be used if some linted files are not under project base directory in the folder hierarchy.

    • Glob patterns that define relative paths to the working directories. For example, with **/foo -* each folder with the name starting with foo- will be used as the working directory for the corresponding linted files.

  4. Choose the configuration to use.

    • Automatic search– select this option if ESLint rules are configured in your a package.json or in a .eslintrc.* file. This can be a .eslintrc, .eslintrc.json, or .eslintrc.yaml file, or a file in another supported format, see the ESLint official website for details.

      IntelliJ IDEA looks for a .eslintrc.* file or for a eslintConfig property in a package.json. IntelliJ IDEA starts the search from the folder where the file to be checked is stored, then searches in its parent folder, and so on until the project root is reached.

    • Configuration File– select this option to use a custom file and specify the file location in the Path field.

    Learn more about configuring ESLint from the ESLint official website.

  5. Optionally:

    • In the Extra eslint options field, specify additional command-line options to run ESLint with, use spaces as separators.

      Learn more about ESLint CLI options from the ESLint official website.

    • In the Additional rules directory field, specify the location of the files with additional code verification rules. These rules will be applied after the rules from package.json, .eslintrc.*, or a custom configuration file and accordingly will override them.

      See the ESLint official website for more information about ESLint configuration files and adding rules.

Configure linting scope

  1. Open the Settings/Preferences dialog ⌘,, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select Automatic ESLint configuration or Manual ESLint configuration.

  2. In the Run for files field, specify the pattern that defines the set of files to be linted. You can accept the default pattern or type a custom one.

    With the default pattern, {**/*,*}.{js,ts,jsx,tsx,html,vue}, ESLint will wake up and process any updated JavaScript, TypeScript, JSX, TSX, HTML, or Vue file. To lint files of other types or files stored in specific folders, use glob patterns to update the default pattern.

    • For example, to automatically reformat CoffeeScript files as well, add coffee to the default pattern as follows:

      {**/*,*}.{js,ts,jsx,tsx,html,vue,coffee}
      

      Copied!

    • To lint files from a specific folder, replace {**/*,*} with <path to the folder>*.

      Suppose, you have a project with the following structure:

      ESLint: custom patterns. Example project structure

      To lint only the files in the coffee folder, update the pattern as follows:

      coffee/*.{js,ts,jsx,tsx,html,vue,coffee}
      

      Copied!

      As a result, the file linting.coffee will be linted while no_linting.coffee will not.

Fix problems automatically on save

ESLint can fix the detected problems every time your changes are saved either manually, with ⌘S, or automatically, when you launch a run/debug configuration, or close IntelliJ IDEA, or perform version control actions, see Autosave for details.

  • Open the Settings/Preferences dialog ⌘,, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select the Run eslint –fix on save checkbox.

Lint your code

When installed and enabled, ESLint activates automatically every time you open a JavaScript file.

By default, IntelliJ IDEA marks detected problems based on the severity levels from the ESLint configuration. See Configuring ESLint highlighting to learn how to override these settings.

Descriptions of the errors detected in the current file and quick-fixes for them are available from the editor and from the Current File tab of the Problems tool window.

Errors in all previously opened files and quick-fixes for them are shown in the Project Errors tab of the Problems tool window. To open the tool window, click the Inspection widget in the upper-right corner of the editor:

Inspection widget

See View problems and apply quick-fixes in the editor and Problems tool window for details.

View problems and apply quick-fixes in the editor

  • To view the description of a problem, hover over the highlighted code.

    ESLint: errors and warnings are highlighted, the description of a problem is shown in a tooltip.

    To resolve the detected problem, click ESLint: Fix '' or press ⌥⇧↩.

    To resolve all the detected problems in the current file, click More actions (⌥⏎) and select ESLint: Fix current file from the list.

    ESLint: resolving problems

    See View problems and apply quick-fixes in the editor for details.

  • Alternatively open the Current File tab of the Problems tool window ⌘6, where you can view problem descriptions, apply quick-fixes, navigate to the fragments in the source code where errors occurred, as well as fix them in the Editor Preview pane without leaving the tool window. Learn more from Problems tool window.

  • You can also configure ESLint to fix all the problems in a file when this file is saved. To configure such behavior, select the Run eslint –fix on save checkbox on the ESLint page of the Settings dialog as described in Activating and configuring ESLint in IntelliJ IDEA.

Lint your code in the Problems tool window

To open the Problems tool window, click the Inspections widget in the upper-right corner of the editor.

Inspection widget

Alternatively select View | Tool windows | Problems from the main menu or press ⌘6.

The Project Errors tab shows the errors in all files that were opened during the current session, with error messages grouped by files in which they were detected.

Problems tool window, ESLint. Project Errors tab shows syntax errors in previously opened files across the project

Here you can view problem descriptions, apply quick-fixes, navigate to the fragments in the source code where errors occurred, as well as fix them in the Editor Preview pane without leaving the tool window. Learn more from Problems tool window.

Configure highlighting for ESLint

By default, IntelliJ IDEA marks the detected errors and warnings based on the severity levels from the ESLint configuration. For example, errors are highlighted with a red squiggly line, while warnings are marked with a yellow background. See Code inspections and Change inspection severity for details.

Change the severity level of a rule in the ESLint configuration

  • In .eslintrc or under eslintConfig in package.json, locate the rule you want to edit and set its ID to 1 warn or to 2 error.

    Learn more from the ESLint official website.

You can override the severities from the ESLint configuration so that IntelliJ IDEA ignores them and shows everything reported by the linter as errors, warnings, or in a custom color.

Ignore the severity levels from the configuration

  1. In the Settings/Preferences dialog ⌘,, select Editor | Inspections. The Inspections page opens.

  2. In the central pane, go to JavaScript | Code quality tools | ESLint.

  3. In the right-hand pane, clear the Use rule severity from the configuration file checkbox and select the severity level to use instead of the default one.

    Specifying a custom severity level for ESLint

Import code style from ESLint

You can import some of the ESLint code style rules to the IntelliJ IDEA JavaScript code style settings. That enables IntelliJ IDEA to use more accurate code style options for your project when auto-completing, generating, or refactoring the code or adding import statements. When you use the Reformat action, IntelliJ IDEA will then no longer break properly formatted code from the ESLint perspective.

IntelliJ IDEA understands ESLint configurations in all official formats: .eslintrc JSON files, package.json files with the eslintConfig field, as well as JavaScript and YAML configuration files.

  • When you open your project for the first time, IntelliJ IDEA imports the code style from the project ESLint configuration automatically.

  • If your ESLint configuration is updated (manually or from your version control), open it in the editor and choose Apply ESLint Code Style Rules from the context menu.

    Importing ESLint code style rules from JavaScript or YAML configuration files

    Alternatively, just answer Yes to the "Apply code style from ESLint?" question on top of the file.

    IntelliJ IDEA suggests importing the code style from ESLint

    The list of applied rules is shown in the Event log tool window:

    Event log tool window shows the list of applied ESLint rules

Use JavaScript Standard Style

You can set JavaScript Standard Style as default JavaScript code style for your application so its main rules are applied when you type the code or reformat it. Since Standard is based on ESLint, you can also use Standard via the IntelliJ IDEA ESLint integration.

Install JavaScript Standard

Enable linting with Standard via ESLint

If you open a project where standard is listed in the project's package.json file, IntelliJ IDEA enables linting with Standard automatically.

  1. In the Settings/Preferences dialog ⌘,, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint.
  2. On the ESLint page that opens, select Manual ESLint configuration and specify the location of the standard package in the ESLint Package field.

Set the JavaScript Standard Style as default

  1. In the Settings/Preferences dialog ⌘,, go to Editor | Code Style | JavaScript.
  2. On the Code Style. JavaScript page that opens, click Set from, and then select JavaScript Standard Style. The style will replace your current scheme.

 

https://www.jetbrains.com/help/idea/linters.html#ws_js_linters_general_problems_tool_window

JavaScript lintersUltimate

Last modified: 08 March 2021

IntelliJ IDEA integrates with ESLint and other most popular JavaScript code linters that detect problems in your code without executing it.

When installed and enabled, a linter activates automatically every time you open a JavaScript file, reports detected errors and warnings, and suggests quick-fixes where possible.

Descriptions of the errors detected in the current file and quick-fixes for them are available from the editor and from the Current File tab of the Problems tool window.

Errors in all previously opened files and quick-fixes for them are shown in the Project Errors tab of the Problems tool window. To open the tool window, click the Inspection widget in the upper-right corner of the editor:

Inspection widget

See View problems and apply quick-fixes in the editor and Problems tool window for details.

View problems and apply quick-fixes in the editor

  1. In the editor, hover the mouse pointer over the highlighted problem. IntelliJ IDEA shows a tooltip with a description of the problem.

    JavaScript linters: errors and warnings are highlighted, the description of a problem is shown in a tooltip.

    To resolve the problem, click : Fix '' or press ⌥⇧↩.

  2. To resolve all the detected problems in the current file, click More actions (⌥⏎) and select : Fix current file from the list.

    JavaScript linters: resolving problems

    Alternatively, press ⌥⏎ and choose the relevant suggestion from the list.

Problems tool window

To open the Problems tool window, click the Inspections widget in the upper-right corner of the editor.

Inspection widget

Alternatively select View | Tool windows | Problems from the main menu or press ⌘6.

The Problems tool window consists of two tabs:

  • The Current File tab shows the errors detected in the file from the active editor tab.

    Problems tool window, TypeScript. Current File tab shows syntax errors from the file in the active editor tab

  • The Project Errors tab shows the errors in all previously opened files, with error messages grouped by files in which they were detected.

    Problems tool window, TypeScript. Project Errors tab shows syntax errors across the project

For each error IntelliJ IDEA shows a brief description and the number of the line where the error occurred. From an error message, you can navigate to the code where the problem occurred, or apply a quick-fix, or fix the problem manually in the Editor Preview pane (the Open Preview button ).

  • To open the Problems tool window, click the Inspections widget in the upper-right corner of the editor.

     

    Alternatively select View | Tool windows | Problems from the main menu or press ⌘6.

  • To view suggested quick-fixes for a problem, select the corresponding error message and then select Show Quick Fixes from its context menu, or click the Show Quick Fixes button on the toolbar, or just press ⌥⏎.

    To fix a problem, select the appropriate quick-fix from the list.

    Problems tool window: fix a problem

  • Alternatively, click the Open Editor Preview button to open the Editor Preview pane and fix the problem manually there, without leaving the tool window.

    https://resources.jetbrains.com/help/img/idea/2021.1/ws_js_linters_problems_tw_preview_pane_light.png

    Gif

  • To resolve the detected problems in the whole file, select : Fix current file from the context menu.

  • To navigate to the place where an error occurred, double-click the corresponding error message, or select Jump to Source from its context menu, or just press ⌘↓.

  • You can also edit the linter's settings, suppress a rule in the statement where a problem occurred or in the whole file, as well as exclude the current file from analysis at all. See Disable and suppress inspections for details.

    Problems tool window: context menu

  • To filter out error messages by their severity and customize their sorting, click the View Options button and select or clear the relevant items in the list.

    https://resources.jetbrains.com/help/img/idea/2021.1/ws_js_linters_problems_tw_view_options_light.png

    Gif

  • To copy an error message, select Copy Problem Description from its context menu or press ⌘C.

 


https://www.jetbrains.com/help/idea/debugging-javascript-in-chrome.html#debug_workers

Debug JavaScript in ChromeUltimate

Last modified: 25 March 2021

IntelliJ IDEA provides a built-in debugger for your client-side JavaScript code that works with Chrome. The video and the instructions below walk you through the basic steps to get started with this debugger.

 

Before you start

  • Make sure the JavaScript Debugger bundled plugin is enabled on the Settings/Preferences | Plugins page, see Managing plugins for details.

Debugging an application running on the built-in server

IntelliJ IDEA has a built-in web server that can be used to preview and debug your application. This server is always running and does not require any manual configuration. All the project files are served on the built-in server with the root URL http://localhost:/, with respect to the project structure.

Start debugging

  1. Set the breakpoints in the JavaScript code, as required.

  2. Open the HTML file that references the JavaScript to debug or select the HTML file in the Project tool window.

  3. From the context menu of the editor or the selection, choose Debug <HTML_file_name>. IntelliJ IDEA generates a debug configuration and starts a debugging session through it. The file opens in the browser, and the Debug tool window appears.

     

    To save the automatically generated configuration for further re-use, choose Save <HTML_file_name> from the context menu after the debugging session is over.

  4. In the Debug tool window, proceed as usual: step through the program, stop and resume the program execution, examine it when suspended, view actual HTML DOM, run JavaScript code snippets in the Console, and so on..

 

By default, a debugging session starts in a new window with a custom Chrome user data. To open a new Chrome instance with your familiar look-and-feel, configure Chrome in IntelliJ IDEA to start with your user data, see Starting a debugging session with your default Chrome user data for details.

Example

Suppose you have a simple application that consists of an index.html file and an index.js file, where index.html references index.js. To start debugging this application using the built-in server, open index.html in the editor and choose Debug 'index.html' from the context menu:

ws_quick_start_debug_built_in_server_1.png

IntelliJ IDEA creates a run/debug configuration automatically, and a debugging session starts:

ws_quick_start_debug_built_in_server_2.png

To restart the new run/debug configuration, click the Debug button in the upper right-hand corner of the IntelliJ IDEA window or choose Run | Debug from the main menu:

ws_quick_start_debug_built_in_server_3.png

Debugging an application running on an external web server

Often you may want to debug client-side JavaScript running on an external development web server, for example powered by Node.js.

Start debugging

  1. Set the breakpoints in the JavaScript code, as required.

  2. Run the application in the development mode. Often you need to run npm start for that.

    When the development server is ready, copy the URL address at which the application is running in the browser – you will need to specify this URL address in the run/debug configuration.

  3. Create a debug configuration of the type JavaScript Debug: from the main menu, select Run | Edit Configuration, click the Add button on the toolbar and select JavaScript Debug from the list. In the Run/Debug Configuration: JavaScript Debug dialog that opens, specify the URL address at which the application is running. This URL can be copied from the address bar of your browser as described in Step 2 above. Click OK to save the configuration settings.

  4. Select the newly created configuration from the Select run/debug configuration list on the toolbar and click the Debug button next to the list. The URL address specified in the run configuration opens in the browser and the Debug tool window appears.

  5. In the Debug tool window, proceed as usual: step through the program, stop and resume the program execution, examine it when suspended, view actual HTML DOM, run JavaScript code snippets in the Console, and so on..

See Debugging React Applications and Debugging Angular Applications for examples.

Debugging asynchronous code

IntelliJ IDEA supports debugging asynchronous client-side JavaScript code. IntelliJ IDEA recognizes breakpoints inside asynchronous code, stops at them, and lets you step into such code. As soon as a breakpoint inside an asynchronous function is hit or you step into asynchronous code, a new element Async call from <caller> is added in the Frames pane of the Debugger tab. IntelliJ IDEA displays a full call stack, including the caller and the entire way to the beginning of the asynchronous actions.

The image below shows an example of a JavaScript debugging session.

ws_debug_tool_window_async.png

The debugger stops at line3(breakpoint), then at line5(breakpoint). On clicking Step into, the debugger will stop at line5 (on function ), then will move to line6.

 

The asynchronous debugging mode is turned on by default. To disable asynchronous stack traces, set js.debugger.async.call.stack.depth in Registry to 0.

Debugging workers

IntelliJ IDEA supports debugging Service Workers and Web Workers. IntelliJ IDEA recognizes breakpoints in each worker and shows the debug data for it as a separate thread in the Frames pane on the Debugger tab of the Debug tool window.

Note that IntelliJ IDEA can debug only dedicated workers, debugging for shared workers is currently not supported.

  1. Set the breakpoints in the Workers to debug.

  2. If you are using Service Workers, make sure the Allow unsigned requests checkbox on the Debugger page is selected. Otherwise your service workers may be unavailable during a debug session:

    ws_debug_service_workers.png

  3. Create a debug configuration of the type JavaScript Debug as described above in Debugging client-side JavaScript running on an external web server.

  4. Select the newly created configuration from the Select run/debug configuration list on the toolbar and click Debug the Debug button.

    The HTML file specified in the run configuration opens in the chosen browser and the Debug tool window opens with the Frames list showing all the Workers:

    ws_js_debug_workers_frames.png

     

    To examine the data (variables, watches, and so on) for a Worker, select its thread in the list and view its data in the Variables and Watches panes. When you select another Worker, the contents of the panes are updated accordingly.

https://eslint.org/docs/rules/

Rules

Rules in ESLint are grouped by category to help you understand their purpose.

No rules are enabled by default. The "extends": "eslint:recommended" property in a configuration file enables rules that report common problems, which have a check mark below.

The --fix option on the command line automatically fixes problems (currently mostly whitespace) reported by rules which have a wrench below.

Possible Errors

These rules relate to possible syntax or logic errors in JavaScript code:

    for-direction enforce "for" loop update clause moving the counter in the right direction.
    getter-return enforce return statements in getters
    no-async-promise-executor disallow using an async function as a Promise executor
    no-await-in-loop disallow await inside of loops
    no-compare-neg-zero disallow comparing against -0
    no-cond-assign disallow assignment operators in conditional expressions
    no-console disallow the use of console
    no-constant-condition disallow constant expressions in conditions
    no-control-regex disallow control characters in regular expressions
    no-debugger disallow the use of debugger
    no-dupe-args disallow duplicate arguments in function definitions
    no-dupe-else-if disallow duplicate conditions in if-else-if chains
    no-dupe-keys disallow duplicate keys in object literals
    no-duplicate-case disallow duplicate case labels
    no-empty disallow empty block statements
    no-empty-character-class disallow empty character classes in regular expressions
    no-ex-assign disallow reassigning exceptions in catch clauses
    no-extra-boolean-cast disallow unnecessary boolean casts
    no-extra-parens disallow unnecessary parentheses
    no-extra-semi disallow unnecessary semicolons
    no-func-assign disallow reassigning function declarations
    no-import-assign disallow assigning to imported bindings
    no-inner-declarations disallow variable or function declarations in nested blocks
    no-invalid-regexp disallow invalid regular expression strings in RegExp constructors
    no-irregular-whitespace disallow irregular whitespace
    no-loss-of-precision disallow literal numbers that lose precision
    no-misleading-character-class disallow characters which are made with multiple code points in character class syntax
    no-obj-calls disallow calling global object properties as functions
    no-promise-executor-return disallow returning values from Promise executor functions
    no-prototype-builtins disallow calling some Object.prototype methods directly on objects
    no-regex-spaces disallow multiple spaces in regular expressions
    no-setter-return disallow returning values from setters
    no-sparse-arrays disallow sparse arrays
    no-template-curly-in-string disallow template literal placeholder syntax in regular strings
    no-unexpected-multiline disallow confusing multiline expressions
    no-unreachable disallow unreachable code after return, throw, continue, and break statements
    no-unreachable-loop disallow loops with a body that allows only one iteration
    no-unsafe-finally disallow control flow statements in finally blocks
    no-unsafe-negation disallow negating the left operand of relational operators
    no-unsafe-optional-chaining disallow use of optional chaining in contexts where the undefined value is not allowed
    no-useless-backreference disallow useless backreferences in regular expressions
    require-atomic-updates disallow assignments that can lead to race conditions due to usage of await or yield
    use-isnan require calls to isNaN() when checking for NaN
    valid-typeof enforce comparing typeof expressions against valid strings

Best Practices

These rules relate to better ways of doing things to help you avoid problems:

    accessor-pairs enforce getter and setter pairs in objects and classes
    array-callback-return enforce return statements in callbacks of array methods
    block-scoped-var enforce the use of variables within the scope they are defined
    class-methods-use-this enforce that class methods utilize this
    complexity enforce a maximum cyclomatic complexity allowed in a program
    consistent-return require return statements to either always or never specify values
    curly enforce consistent brace style for all control statements
    default-case require default cases in switch statements
    default-case-last enforce default clauses in switch statements to be last
    default-param-last enforce default parameters to be last
    dot-location enforce consistent newlines before and after dots
    dot-notation enforce dot notation whenever possible
    eqeqeq require the use of === and !==
    grouped-accessor-pairs require grouped accessor pairs in object literals and classes
    guard-for-in require for-in loops to include an if statement
    max-classes-per-file enforce a maximum number of classes per file
    no-alert disallow the use of alert, confirm, and prompt
    no-caller disallow the use of arguments.caller or arguments.callee
    no-case-declarations disallow lexical declarations in case clauses
    no-constructor-return disallow returning value from constructor
    no-div-regex disallow division operators explicitly at the beginning of regular expressions
    no-else-return disallow else blocks after return statements in if statements
    no-empty-function disallow empty functions
    no-empty-pattern disallow empty destructuring patterns
    no-eq-null disallow null comparisons without type-checking operators
    no-eval disallow the use of eval()
    no-extend-native disallow extending native types
    no-extra-bind disallow unnecessary calls to .bind()
    no-extra-label disallow unnecessary labels
    no-fallthrough disallow fallthrough of case statements
    no-floating-decimal disallow leading or trailing decimal points in numeric literals
    no-global-assign disallow assignments to native objects or read-only global variables
    no-implicit-coercion disallow shorthand type conversions
    no-implicit-globals disallow declarations in the global scope
    no-implied-eval disallow the use of eval()-like methods
    no-invalid-this disallow this keywords outside of classes or class-like objects
    no-iterator disallow the use of the __iterator__ property
    no-labels disallow labeled statements
    no-lone-blocks disallow unnecessary nested blocks
    no-loop-func disallow function declarations that contain unsafe references inside loop statements
    no-magic-numbers disallow magic numbers
    no-multi-spaces disallow multiple spaces
    no-multi-str disallow multiline strings
    no-new disallow new operators outside of assignments or comparisons
    no-new-func disallow new operators with the Function object
    no-new-wrappers disallow new operators with the String, Number, and Boolean objects
    no-nonoctal-decimal-escape disallow \8 and \9 escape sequences in string literals
    no-octal disallow octal literals
    no-octal-escape disallow octal escape sequences in string literals
    no-param-reassign disallow reassigning function parameters
    no-proto disallow the use of the __proto__ property
    no-redeclare disallow variable redeclaration
    no-restricted-properties disallow certain properties on certain objects
    no-return-assign disallow assignment operators in return statements
    no-return-await disallow unnecessary return await
    no-script-url disallow javascript: urls
    no-self-assign disallow assignments where both sides are exactly the same
    no-self-compare disallow comparisons where both sides are exactly the same
    no-sequences disallow comma operators
    no-throw-literal disallow throwing literals as exceptions
    no-unmodified-loop-condition disallow unmodified loop conditions
    no-unused-expressions disallow unused expressions
    no-unused-labels disallow unused labels
    no-useless-call disallow unnecessary calls to .call() and .apply()
    no-useless-catch disallow unnecessary catch clauses
    no-useless-concat disallow unnecessary concatenation of literals or template literals
    no-useless-escape disallow unnecessary escape characters
    no-useless-return disallow redundant return statements
    no-void disallow void operators
    no-warning-comments disallow specified warning terms in comments
    no-with disallow with statements
    prefer-named-capture-group enforce using named capture group in regular expression
    prefer-promise-reject-errors require using Error objects as Promise rejection reasons
    prefer-regex-literals disallow use of the RegExp constructor in favor of regular expression literals
    radix enforce the consistent use of the radix argument when using parseInt()
    require-await disallow async functions which have no await expression
    require-unicode-regexp enforce the use of u flag on RegExp
    vars-on-top require var declarations be placed at the top of their containing scope
    wrap-iife require parentheses around immediate function invocations
    yoda require or disallow "Yoda" conditions

Strict Mode

These rules relate to strict mode directives:

    strict require or disallow strict mode directives
       

Variables

These rules relate to variable declarations:

    init-declarations require or disallow initialization in variable declarations
    no-delete-var disallow deleting variables
    no-label-var disallow labels that share a name with a variable
    no-restricted-globals disallow specified global variables
    no-shadow disallow variable declarations from shadowing variables declared in the outer scope
    no-shadow-restricted-names disallow identifiers from shadowing restricted names
    no-undef disallow the use of undeclared variables unless mentioned in /*global */ comments
    no-undef-init disallow initializing variables to undefined
    no-undefined disallow the use of undefined as an identifier
    no-unused-vars disallow unused variables
    no-use-before-define disallow the use of variables before they are defined

Stylistic Issues

These rules relate to style guidelines, and are therefore quite subjective:

    array-bracket-newline enforce linebreaks after opening and before closing array brackets
    array-bracket-spacing enforce consistent spacing inside array brackets
    array-element-newline enforce line breaks after each array element
    block-spacing disallow or enforce spaces inside of blocks after opening block and before closing block
    brace-style enforce consistent brace style for blocks
    camelcase enforce camelcase naming convention
    capitalized-comments enforce or disallow capitalization of the first letter of a comment
    comma-dangle require or disallow trailing commas
    comma-spacing enforce consistent spacing before and after commas
    comma-style enforce consistent comma style
    computed-property-spacing enforce consistent spacing inside computed property brackets
    consistent-this enforce consistent naming when capturing the current execution context
    eol-last require or disallow newline at the end of files
    func-call-spacing require or disallow spacing between function identifiers and their invocations
    func-name-matching require function names to match the name of the variable or property to which they are assigned
    func-names require or disallow named function expressions
    func-style enforce the consistent use of either function declarations or expressions
    function-call-argument-newline enforce line breaks between arguments of a function call
    function-paren-newline enforce consistent line breaks inside function parentheses
    id-denylist disallow specified identifiers
    id-length enforce minimum and maximum identifier lengths
    id-match require identifiers to match a specified regular expression
    implicit-arrow-linebreak enforce the location of arrow function bodies
    indent enforce consistent indentation
    jsx-quotes enforce the consistent use of either double or single quotes in JSX attributes
    key-spacing enforce consistent spacing between keys and values in object literal properties
    keyword-spacing enforce consistent spacing before and after keywords
    line-comment-position enforce position of line comments
    linebreak-style enforce consistent linebreak style
    lines-around-comment require empty lines around comments
    lines-between-class-members require or disallow an empty line between class members
    max-depth enforce a maximum depth that blocks can be nested
    max-len enforce a maximum line length
    max-lines enforce a maximum number of lines per file
    max-lines-per-function enforce a maximum number of lines of code in a function
    max-nested-callbacks enforce a maximum depth that callbacks can be nested
    max-params enforce a maximum number of parameters in function definitions
    max-statements enforce a maximum number of statements allowed in function blocks
    max-statements-per-line enforce a maximum number of statements allowed per line
    multiline-comment-style enforce a particular style for multiline comments
    multiline-ternary enforce newlines between operands of ternary expressions
    new-cap require constructor names to begin with a capital letter
    new-parens enforce or disallow parentheses when invoking a constructor with no arguments
    newline-per-chained-call require a newline after each call in a method chain
    no-array-constructor disallow Array constructors
    no-bitwise disallow bitwise operators
    no-continue disallow continue statements
    no-inline-comments disallow inline comments after code
    no-lonely-if disallow if statements as the only statement in else blocks
    no-mixed-operators disallow mixed binary operators
    no-mixed-spaces-and-tabs disallow mixed spaces and tabs for indentation
    no-multi-assign disallow use of chained assignment expressions
    no-multiple-empty-lines disallow multiple empty lines
    no-negated-condition disallow negated conditions
    no-nested-ternary disallow nested ternary expressions
    no-new-object disallow Object constructors
    no-plusplus disallow the unary operators ++ and --
    no-restricted-syntax disallow specified syntax
    no-tabs disallow all tabs
    no-ternary disallow ternary operators
    no-trailing-spaces disallow trailing whitespace at the end of lines
    no-underscore-dangle disallow dangling underscores in identifiers
    no-unneeded-ternary disallow ternary operators when simpler alternatives exist
    no-whitespace-before-property disallow whitespace before properties
    nonblock-statement-body-position enforce the location of single-line statements
    object-curly-newline enforce consistent line breaks after opening and before closing braces
    object-curly-spacing enforce consistent spacing inside braces
    object-property-newline enforce placing object properties on separate lines
    one-var enforce variables to be declared either together or separately in functions
    one-var-declaration-per-line require or disallow newlines around variable declarations
    operator-assignment require or disallow assignment operator shorthand where possible
    operator-linebreak enforce consistent linebreak style for operators
    padded-blocks require or disallow padding within blocks
    padding-line-between-statements require or disallow padding lines between statements
    prefer-exponentiation-operator disallow the use of Math.pow in favor of the ** operator
    prefer-object-spread disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.
    quote-props require quotes around object literal property names
    quotes enforce the consistent use of either backticks, double, or single quotes
    semi require or disallow semicolons instead of ASI
    semi-spacing enforce consistent spacing before and after semicolons
    semi-style enforce location of semicolons
    sort-keys require object keys to be sorted
    sort-vars require variables within the same declaration block to be sorted
    space-before-blocks enforce consistent spacing before blocks
    space-before-function-paren enforce consistent spacing before function definition opening parenthesis
    space-in-parens enforce consistent spacing inside parentheses
    space-infix-ops require spacing around infix operators
    space-unary-ops enforce consistent spacing before or after unary operators
    spaced-comment enforce consistent spacing after the // or /* in a comment
    switch-colon-spacing enforce spacing around colons of switch statements
    template-tag-spacing require or disallow spacing between template tags and their literals
    unicode-bom require or disallow Unicode byte order mark (BOM)
    wrap-regex require parenthesis around regex literals

ECMAScript 6

These rules relate to ES6, also known as ES2015:

    arrow-body-style require braces around arrow function bodies
    arrow-parens require parentheses around arrow function arguments
    arrow-spacing enforce consistent spacing before and after the arrow in arrow functions
    constructor-super require super() calls in constructors
    generator-star-spacing enforce consistent spacing around * operators in generator functions
    no-class-assign disallow reassigning class members
    no-confusing-arrow disallow arrow functions where they could be confused with comparisons
    no-const-assign disallow reassigning const variables
    no-dupe-class-members disallow duplicate class members
    no-duplicate-imports disallow duplicate module imports
    no-new-symbol disallow new operators with the Symbol object
    no-restricted-exports disallow specified names in exports
    no-restricted-imports disallow specified modules when loaded by import
    no-this-before-super disallow this/super before calling super() in constructors
    no-useless-computed-key disallow unnecessary computed property keys in objects and classes
    no-useless-constructor disallow unnecessary constructors
    no-useless-rename disallow renaming import, export, and destructured assignments to the same name
    no-var require let or const instead of var
    object-shorthand require or disallow method and property shorthand syntax for object literals
    prefer-arrow-callback require using arrow functions for callbacks
    prefer-const require const declarations for variables that are never reassigned after declared
    prefer-destructuring require destructuring from arrays and/or objects
    prefer-numeric-literals disallow parseInt() and Number.parseInt() in favor of binary, octal, and hexadecimal literals
    prefer-rest-params require rest parameters instead of arguments
    prefer-spread require spread operators instead of .apply()
    prefer-template require template literals instead of string concatenation
    require-yield require generator functions to contain yield
    rest-spread-spacing enforce spacing between rest and spread operators and their expressions
    sort-imports enforce sorted import declarations within modules
    symbol-description require symbol descriptions
    template-curly-spacing require or disallow spacing around embedded expressions of template strings
    yield-star-spacing require or disallow spacing around the * in yield* expressions

Deprecated

These rules have been deprecated in accordance with the deprecation policy, and replaced by newer rules:

Deprecated rule Replaced by
callback-return (no replacement)
global-require (no replacement)
handle-callback-err (no replacement)
id-blacklist id-denylist
indent-legacy indent
lines-around-directive padding-line-between-statements
newline-after-var padding-line-between-statements
newline-before-return padding-line-between-statements
no-buffer-constructor (no replacement)
no-catch-shadow no-shadow
no-mixed-requires (no replacement)
no-native-reassign no-global-assign
no-negated-in-lhs no-unsafe-negation
no-new-require (no replacement)
no-path-concat (no replacement)
no-process-env (no replacement)
no-process-exit (no replacement)
no-restricted-modules (no replacement)
no-spaced-func func-call-spacing
no-sync (no replacement)
prefer-reflect (no replacement)
require-jsdoc (no replacement)
valid-jsdoc (no replacement)

Removed

These rules from older versions of ESLint (before the deprecation policy existed) have been replaced by newer rules:

Removed rule Replaced by
generator-star generator-star-spacing
global-strict strict
no-arrow-condition no-confusing-arrow no-constant-condition
no-comma-dangle comma-dangle
no-empty-class no-empty-character-class
no-empty-label no-labels
no-extra-strict strict
no-reserved-keys quote-props
no-space-before-semi semi-spacing
no-wrap-func no-extra-parens
space-after-function-name space-before-function-paren
space-after-keywords keyword-spacing
space-before-function-parentheses space-before-function-paren
space-before-keywords keyword-spacing
space-in-brackets object-curly-spacing array-bracket-spacing
space-return-throw-case keyword-spacing
space-unary-word-ops space-unary-ops
spaced-line-comment spaced-comment

 

Scroll to Top