Repository navigation
style: fix lint violations surfaced by the Nx 24 lint targets - #11685
Merged
Merged
Conversation
|
View your CI Pipeline Execution ↗ for commit 93a4ed1
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
3 of 5 tasks
NathanWalker
force-pushed
the
chore/lint-nx24-violations
branch
from
November 28, 2026 00:17
f824d5b to
9e36e46
Compare
NathanWalker
force-pushed
the
chore/lint-nx24-violations
branch
from
November 28, 2026 00:30
9e36e46 to
c0bdaa3
Compare
Declare @angular-devkit/schematics, which the app generator imports, and drop tslib, which nothing uses (importHelpers is off). Also remove the unused eslint-disable directive from jest.config.ts.
…heck apps/automated has one platform-conditional require() of @nativescript/core/ui/animation. Nx records require() as a dynamic dependency, so enforce-module-boundaries reported every static @nativescript/core import in the project (429 errors) as a static import of a lazy-loaded library. NativeScript apps bundle core whole and never code-split it, so the check does not apply to core.
prefer-const only.
prefer-const, plus one function-local no-var.
no-var, prefer-const and one no-extra-boolean-cast. ESLint only autofixes a var when no reference precedes it; a check for hoisted function declarations that could reach a converted binding before its declaration found none.
no-var and prefer-const. ESLint only autofixes a var when no reference precedes it and it is not captured per-iteration in a loop; a check for hoisted function declarations or callbacks that could reach a converted binding before its declaration found none.
…ence.d.ts It is the automated app's counterpart of the references.d.ts files the rule is already off for: a triple-slash reference is how it pulls in core's ambient types.
- no-var on exported and early-referenced declarations (ESLint never autofixes these): var -> let, then prefer-const autofix. References that precede a declaration are all inside test functions or callbacks that cannot run before it. - application-tests.ios.ts: declare the observer before the if-block it was assigned in. - xml-parser-tests.ts: give the two case clauses that declared variables their own block. - repeater-tests.ts: the date converter read month before declaring it when padding the day; pad on day, as the list-view copy does. - file-system-tests.ts and globals.d.ts keep var, with a reason. - prefer-const on `let x; ... x = v;`: declare at the assignment. - prefer-as-const: apply the rule's suggestion. - no-constant-binary-expression, no-unused-expressions, prefer-spread: assert(true), drop a bare ModuleNameResolver statement, spread instead of Array.apply.
Mark the intentional empty-case fallthroughs in the optimizeDeps flavor switch, and write the BOM in the css-device-module regex as \uFEFF instead of a literal U+FEFF. No behavior change.
Covers the typed-array body tests and the fragment TransitionListener that landed on main after the initial pass.
apps/*/platforms holds generated bundles after a local ns build; linting them reports thousands of errors.
NathanWalker
force-pushed
the
chore/lint-nx24-violations
branch
from
November 28, 2026 00:33
c0bdaa3 to
93a4ed1
Compare
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
What is the current behavior?
Stacked on #11684 (
chore/nx-24). Under Nx 24 the inferred@nx/eslint/pluginlint tasks lint webpack5, the three apps and workspace-plugin for the first time, and they report existing violations. #11684 left them as an open question. This PR fixes them.What is the new behavior?
Every project's lint target passes. No rule is turned off for a whole project.
Lint results (
nx run <project>:lint --skip-nx-cache)By rule:
no-varvaror one referenced before its declaration, so these wentvartolet, thenprefer-constautofix. One kept asvarwith a reason.prefer-constlet x; … x = v;cases merged by hand intoconst x = v;@nx/enforce-module-boundaries@typescript-eslint/prefer-as-const= 'row' as const)no-constant-binary-expressionTKUnit.assert(true === true)→TKUnit.assert(true)@typescript-eslint/triple-slash-reference@typescript-eslint/no-unused-expressionsModuleNameResolver;statementprefer-spreadArray.apply(null, Array(10))→[...Array(10)]no-varvar→constby handprefer-constno-extra-boolean-cast!!!x→!x)prefer-const/no-varprefer-const@nx/dependency-checkseslint-disable(warning)no-fallthrough// falls throughto the two intentional empty-case fallthroughsno-irregular-whitespace/^<literal U+FEFF>/→/^/(same regex)Left as is: the apps-ui warning (an unused
require('webpack')inapps/ui/webpack.config.js), and the core and vite warnings (no-this-alias, and "Unused eslint-disable directive" from ESLint 9'sreportUnusedDisableDirectives).Checking
var→let/constapps/automatedruns only on a device, so a temporal dead zone (TDZ) error would only show up at runtime. The changes were checked for this:no-varautofix skips anyvarthat is referenced before its declaration, captured per-iteration in a loop, redeclared, used outside its block, or declared directly in acase._createButtonFunc, used by theexport const test… = functionbodies above it) are all read only inside test functions, and those run after the module has loaded.var→constdoes not change how the test runner finds tests: it enumerates module exports, and nothing reassigns them. Type checking would report any reassignment of aconst.Hand fixes where
varsemantics mattered:application/application-tests.ios.ts:observerwas declared withvarinside anifand used after it. It is now declared before theif.xml-parser-tests.ts: twocaseclauses declared variables. They now have their own block, whichno-case-declarationsrequires.ui/repeater/repeater-tests.ts: the date converter padded the day usingmonthbefore declaring it (hoisted, so alwaysundefined). Withconstthis would throw. It now pads onday, the same as the identical converter inlist-view-tests.ts. The test compares the converter against itself, so its result doesn't change.varwith aneslint-disable-next-line no-var -- <reason>:file-system/file-system-tests.ts:const globalConsole = console; var console = {…}relies on hoisting.globalConsolereadsundefinedtoday; withletit would throw.globals.d.ts:declare var __CI__, because an ambient global needsdeclare varto also exist onglobalThis.Config decisions
@nx/enforce-module-boundaries"lazy-loaded library" (429 errors). The cause is a single line inapps/automated/src/ui/animation/animation-tests.ts:require('@nativescript/core/ui/animation')._getTransformMismatchErrorMessage. It is arequire()because that function exists only inindex.ios.tsand isn't declared in the.d.ts. Nx recordsrequire()as a dynamic dependency, so the rule treatedcoreas lazy-loaded and reported every static@nativescript/coreimport in the project. The fix sets the rule'scheckDynamicDependenciesExceptions: ['@nativescript/core', '@nativescript/core/**']in the root config. NativeScript apps bundle core whole and never code-split it, so the check doesn't apply to core. Every other module-boundary check (dependency constraints, buildable-lib, circular) is still enforced. I chose this over rewriting the test import: therequire()is a legitimate platform-conditional lookup, and the rule would fire again the next time a test does the same thing.@typescript-eslint/triple-slash-reference. The root config already turns it off for**/references.d.ts.apps/automated/reference.d.tsis the same file under a singular name, so it was added to that override.workspace-plugin
@nx/dependency-checksreported that the app generator imports@angular-devkit/schematicsbutpackage.jsondoesn't declare it, and thattslibis declared but unused (importHelpersis off).@angular-devkit/schematicsis now declared as^18.2.21, the installed version, andtslibis removed. The rootpackage.jsonand the lockfile are unchanged: the package arrives transitively through@nstudio/focus.Formatting
The pre-commit
lint-stagedhook ran Prettier on each touched file. In apps/ui and apps/automated it also reformatted about 20 lines next to the fixes (trailing commas, wrapped constructor parameters).prettier --checkpasses on every changed file.Commits
fix(workspace-plugin): declare dependenciesbuild(lint): exempt @nativescript/core from the lazy-loaded library checkstyle(webpack5): apply eslint autofixesstyle(apps): apply eslint autofixes to toolboxstyle(apps): apply eslint autofixes to uistyle(apps): apply eslint autofixes to automatedbuild(lint): allow the triple-slash reference in apps/automated/reference.d.tsfix(apps): resolve the lint errors that autofix leaves in the test appsstyle(vite): fix the remaining lint errorsstyle: fix lint errors in code added since the lint sweep: twoexport vartyped-array body tests (fix(http): send typed array, DataView and Blob request bodies #11654) and a never-reassignedlet TransitionListener(fix(android): stop fragment transition listeners from holding their transition #11656) that reached main after the sweep.build(lint): ignore native platform build output in apps:apps/**/platforms/**is generated by a localns buildand is gitignored; without the ignore,apps-automated:lintreports thousands of errors from the bundled.mjsfiles.Verification
The baseline is
chore/nx-24afternpm ci. Everything ran with--skip-nx-cache.tsc --noEmitforapps/automated,apps/ui,apps/toolboxtsc --noEmitfor webpack5 (tsconfig.json,tsconfig.lib.json) and workspace-plugin (tsconfig.lib.json,tsconfig.spec.json)core:testvite:testwebpack5:testworkspace-plugin:testnx run-many -t build -p core,webpack5,viteworkspace-plugin:buildprettier --check(changed files)The
apps/automateddevice suite wasn't run locally. Theapps/automated/iosandapps/automated/androidworkflows run on this PR.Notes
externalSchematic('@nx/workspace', 'lib', …), an Angular-devkit schematic bridge. Its dependency is now declared, but whether that schematic still exists under Nx 24 wasn't checked. The generator may be dead code.