Skip to content

How an ESLint Rule Reaches a Pull Request

An ESLint rule for Salesforce JavaScript passes three places before it can stop a pull request, and each place decides something different. A rule that stops a commit on a developer's computer may therefore not be reported on the pull request at all. This page sets out the three places, follows one rule through them, and lists the rules on which they differ.

The Three Places

Place What it decides Where that is written
The Salesforce ESLint packages Whether a rule is on, and its level: error or warning. In @salesforce/eslint-config-lwc and @salesforce/eslint-plugin-aura. The repository's eslint.config.js loads them (Version Control: ESLint).
Salesforce Code Analyzer A severity from 1 to 5 for each rule, and its tags. The tag Recommended decides whether a rule runs by default. In Code Analyzer's own list of rules, eslint-base.ts and the files beside it.
The repository's code-analyzer.yml, and the gate The severity and the tags that a rule has in this repository, and which rules the gate runs and blocks on. In code-analyzer.yml (the sample) and in the workflow (Appendix E).

The three do not read one another's answers. Code Analyzer does not take the level of a rule from the ESLint packages: it has a severity of its own for every rule it knows. The gate does not take the severity from Code Analyzer where code-analyzer.yml gives another.

How a Rule Passes Along

  • ESLint alone. In the editor and at a commit, ESLint uses the levels set by the packages. An error stops the commit (Local Checks Before the Push).
  • Code Analyzer. It runs ESLint with the repository's file, and reports each rule at its own severity. With its default selection it runs only the rules tagged Recommended.
  • The gate. It runs the rules tagged Recommended and the rules tagged DevSecOps, and a rule at severity 1 or 2 blocks the pull request (Severity Levels).

So a rule that is an error in the packages ends in one of four ways on a pull request:

In Code Analyzer On the pull request
Severity 1 or 2, and tagged Recommended It is reported, and it blocks. The two agree.
Severity 3 or lower, and tagged Recommended It is reported, and it does not block.
Severity 1 or 2, and not tagged Recommended It is not run.
Severity 3 or lower, and not tagged Recommended It is not run, and it would not block if it were.

A repository changes the outcome for a rule in code-analyzer.yml: it gives the rule severity 2, and a tag that the gate selects.

A developer sees the gate's answer in the editor with the Salesforce Code Analyzer extension, which reads the same code-analyzer.yml. The ESLint extension shows the answer of the packages. These standards recommend the first (Version Control: ESLint), with the settings that make it run the same rules as the gate (Appendix E).

One Rule, Followed Through

no-script-url reports a javascript: URL in JavaScript.

The Rules on Which They Differ

The ESLint file of a new Salesforce DX project makes {N} rules an error for the JavaScript of an Aura component or of a Lightning Web Component. Code Analyzer agrees on 56 of them. The tables below hold the other 102, in four groups. An empty cell in the second or third column means that the packages do not make the rule an error for that kind of component.

These standards do not add these rules to their own lists. The last column marks the rules that a standard names, with the severity that the sample code-analyzer.yml gives each of them. An organisation that wants another rule from these tables to block gives it severity 2 and a tag that its gate selects.

The tables were made from Salesforce Code Analyzer 5.16.0, ESLint 9.39.5, @salesforce/eslint-config-lwc 4.1.2, and @salesforce/eslint-plugin-aura 3.0.0. All rules are subject to change in later versions; the Code Analyzer changelog and repository can show updates.

Code Analyzer does not run these rules by default, and they would not block.

Rule Aura components Lightning Web Components In these standards
consistent-return Error Error
default-case Error Error
dot-notation Error Error
eqeqeq Error Error
guard-for-in Error Error
no-alert Error Error
no-caller Error Error
no-else-return Error Error
no-empty-function Error Error
no-empty-static-block Error Error
no-eval Error Error
no-extend-native Error Error Severity 2
no-extra-bind Error Error
no-implied-eval Error Error Severity 2
no-iterator Error Error
no-label-var Error Error
no-labels Error Error
no-loop-func Error Error
no-multi-str Error Error
no-new Error Error
no-new-func Error Error
no-new-wrappers Error Error
no-octal-escape Error Error
no-proto Error Error
no-return-assign Error Error
no-script-url Error Error Severity 2
no-sequences Error Error
no-shadow Error Error
no-throw-literal Error Error
no-undef-init Error Error
no-unused-expressions Error Error
no-useless-concat Error Error
no-useless-return Error Error
no-void Error Error
radix Error Error
vars-on-top Error Error
no-restricted-globals Error
no-restricted-imports Error
no-useless-computed-key Error
no-useless-constructor Error
no-useless-rename Error
no-array-constructor Error
no-console Error Severity 2

Code Analyzer runs these rules, and they do not block.

Rule Aura components Lightning Web Components In these standards
no-case-declarations Error Error
no-delete-var Error Error
no-empty Error Error
no-extra-boolean-cast Error Error
no-global-assign Error Error Severity 2
no-nonoctal-decimal-escape Error Error
no-redeclare Error Error
no-regex-spaces Error Error
no-shadow-restricted-names Error Error Severity 2
no-unused-labels Error Error
no-useless-catch Error Error
no-useless-escape Error Error
no-with Error Error
require-yield Error Error
@lwc/lwc/newer-version-available Error
@lwc/lwc/no-api-reassignments Error
@lwc/lwc/no-async-operation Error
@lwc/lwc/no-attributes-during-construction Error
@lwc/lwc/no-deprecated Error
@lwc/lwc/no-disallowed-lwc-imports Error
@lwc/lwc/no-document-query Error
@lwc/lwc/no-leading-uppercase-api-name Error
@lwc/lwc/no-template-children Error
@lwc/lwc/no-unexpected-wire-adapter-usages Error
@lwc/lwc/no-unknown-wire-adapters Error
@lwc/lwc/prefer-custom-event Error
@lwc/lwc/valid-api Error
@lwc/lwc/valid-graphql-wire-adapter-callback-parameters Error
@lwc/lwc/valid-track Error
@lwc/lwc/valid-wire Error
@salesforce/lightning/valid-apex-method-invocation Error
jest/no-alias-methods Error
jest/no-deprecated-functions Error
jest/no-done-callback Error
jest/no-export Error
jest/no-focused-tests Error
jest/no-identical-title Error
jest/no-jasmine-globals Error
jest/no-standalone-expect Error
jest/no-test-prefixes Error
jest/valid-expect Error
jest/valid-expect-in-promise Error
jest/valid-title Error
@salesforce/aura/getevt-markup-prefix Error
@salesforce/aura/no-deprecated-aura-error Error
@salesforce/aura/no-deprecated-component-creation Error

These rules would block, but Code Analyzer does not run them by default.

Rule Aura components Lightning Web Components In these standards
array-callback-return Error Error
no-constant-binary-expression Error Error
no-new-native-nonconstructor Error Error
no-self-compare Error Error
no-unused-private-class-members Error Error
no-use-before-define Error Error
no-await-in-loop Error

Not in Code Analyzer's List

Code Analyzer has no entry for these rules. ESLint deprecates all six.

Rule Aura components Lightning Web Components In these standards
no-floating-decimal Error Error
no-new-object Error Error
no-return-await Error Error
wrap-iife Error Error
handle-callback-err Error
no-confusing-arrow Error