Skip to content

Stop the LWC rules and the ES2015+ rules from reporting on Aura files - #520

Open
dschach wants to merge 1 commit into
forcedotcom:devfrom
dschach:fix/aura-files-lwc-base-config
Open

dschach wants to merge 1 commit into
forcedotcom:devfrom
dschach:fix/aura-files-lwc-base-config

Conversation

@dschach

@dschach dschach commented Nov 10, 2026

Copy link
Copy Markdown

Fixes #519. The same report is filed as forcedotcom/code-analyzer#2112.

What changes

The ESLint engine's LWC base config and base JavaScript config apply to every .js file, so they also run on the JavaScript of Aura components: the controllers, helpers, and renderers in an aura folder. Salesforce checks that JavaScript with @salesforce/eslint-plugin-aura, as ECMAScript 5, so these rules report correct Aura code. For example, @lwc/lwc-platform/no-aura reports every $A, and no-var reports every var.

base-config.ts now appends one config for **/aura/**/*.js (and the other LWC extensions) that turns off:

  • every rule of the plugins that the LWC base config registers: @lwc/lwc, @lwc/lwc-platform, @salesforce/lightning, import, and jest;
  • the 15 rules of eslintJs.configs.all that ask for syntax that ECMAScript 5 does not have, such as no-var, prefer-const, object-shorthand, and prefer-arrow-callback.

The JavaScript-only path (disable_lwc_base_config: true) gets the second part, and the LWC-only path (disable_javascript_base_config: true) gets the first.

Why rules are turned off and not files ignored

ignores: ['**/aura/**'] on the LWC configs would also unregister their plugins for Aura files. A user config that names an LWC rule for every JavaScript file would then make ESLint throw ("Could not find plugin"). With the rules turned off, the plugins stay registered, and a user config, which comes after the base config, can still turn any of these rules back on for Aura files.

The engine sets each rule's status from the most severe setting across the files, so the rule list does not change for a workspace with Lightning web components. A workspace with only Aura files no longer lists the LWC rules, which do not apply to it.

Tests

A new workspace, test/test-data/workspaceWithAuraFiles, holds the correct Aura controller from the issue and a Lightning web component with the same var and document.querySelector. Four tests in engine.test.ts:

  • defaults: no report on the Aura controller; no-var and @lwc/lwc/no-document-query still reported on the Lightning web component;
  • disable_lwc_base_config: true: the same for the ES2015+ rules;
  • disable_javascript_base_config: true: the same for the LWC rules;
  • a user config that turns on @lwc/lwc/no-document-query for every JavaScript file applies to the Aura file too, and nothing throws.

Without the change, the first three fail and the fourth passes. The existing rule goldfiles are unchanged.

The engine's package.json version goes to 0.48.0-SNAPSHOT, for the snapshot version check. With the change, the engine's build, lint, and tests pass locally (333 tests, with every new line of base-config.ts covered), and so do the snapshot version check and the package interdependency check.

The title

I do not have a work item number, so the title has none and the title check will fail. Please rename the pull request as you need.

🤖 Generated with Claude Code

@git2gus

git2gus Bot commented Nov 10, 2026

Copy link
Copy Markdown

Git2Gus App is installed but the .git2gus/config.json doesn't have right values. You should add the required configuration.

@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Claude AI <c***@n***.g***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated.

The LWC base config and the base JavaScript config apply to every .js file, so the LWC, LWC platform, Lightning, import, and Jest rules, and the rules that ask for syntax that ECMAScript 5 does not have, report correct Aura code. A new config, appended last for the files in an aura folder, turns those rules off. It turns them off rather than ignoring the files, so that the plugins stay registered and a user config that names one of their rules still works.

Fixes forcedotcom#519. Also reported as forcedotcom/code-analyzer#2112.
@dschach
dschach force-pushed the fix/aura-files-lwc-base-config branch from ac7eb68 to af9e95d Compare November 10, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][code-analyzer] ESLint LWC base config runs on Aura controllers and reports correct Aura code

1 participant