style: fix lint violations surfaced by the Nx 24 lint targets by NathanWalker · Pull Request #11685 · NativeScript/NativeScript
Repository navigation
style: fix lint violations surfaced by the Nx 24 lint targets - #11685
Merged
NathanWalker merged 11 commits into main from chore/lint-nx24-violations Nov 28, 2026
Merged
style: fix lint violations surfaced by the Nx 24 lint targets #11685 NathanWalker merged 11 commits into main from chore/lint-nx24-violations
Conversation
NathanWalker commented Nov 25, 2026 · edited Loading
Copy link Copy Markdown
Contributor
PR Checklist
- The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages .
- There is an issue for the bug/feature this PR is for.
- You have signed the CLA .
- All existing tests are passing (same results as the base branch, see Verification).
- Tests for the changes are included (lint-only change).
What is the current behavior?
Stacked on #11684 (chore/nx-24). Under Nx 24 the inferred @nx/eslint/plugin lint 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)
| Project | Before | After |
|---|---|---|
| apps-automated | 3230 errors | 0 |
| apps-ui | 335 errors, 1 warning | 0 errors, 1 warning |
| apps-toolbox | 17 errors | 0 |
| webpack5 | 23 errors | 0 |
| workspace-plugin | 2 errors, 1 warning | 0 |
| core | 0 errors, 23 warnings | 0 errors, 23 warnings (unchanged) |
| vite | 3 errors, 22 warnings | 0 errors, 22 warnings |
By rule:
| Project | Rule | Count | How it was fixed |
|---|---|---|---|
| apps-automated | no-var |
1897 | 1535 by autofix. 361 by hand: ESLint never autofixes an exported var or one referenced before its declaration, so these went var to let, then prefer-const autofix. One kept as var with a reason. |
| apps-automated | prefer-const |
864 | Autofix, except 38 let x; ... x = v; cases merged by hand into const x = v; |
| apps-automated | @nx/enforce-module-boundaries |
429 | Config: see below |
| apps-automated | @typescript-eslint/prefer-as-const |
33 | Applied the rule's suggestion (= 'row' as const) |
| apps-automated | no-constant-binary-expression |
4 | TKUnit.assert(true === true) → TKUnit.assert(true) |
| apps-automated | @typescript-eslint/triple-slash-reference |
1 | Config: see below |
| apps-automated | @typescript-eslint/no-unused-expressions |
1 | Removed a bare ModuleNameResolver; statement |
| apps-automated | prefer-spread |
1 | Array.apply(null, Array(10)) → [...Array(10)] |
| apps-ui | no-var |
171 | 169 by autofix, 2 exported var → const by hand |
| apps-ui | prefer-const |
163 | Autofix |
| apps-ui | no-extra-boolean-cast |
1 | Autofix (!!!x → !x) |
| apps-toolbox | prefer-const / no-var |
16 / 1 | Autofix |
| webpack5 | prefer-const |
23 | Autofix |
| workspace-plugin | @nx/dependency-checks |
2 | Declared the real dependency, dropped the unused one |
| workspace-plugin | unused eslint-disable (warning) |
1 | Removed |
| vite | no-fallthrough |
2 | Added // falls through to the two intentional empty-case fallthroughs |
| vite | no-irregular-whitespace |
1 | /^<literal U+FEFF>/ → /^/ (same regex) |
Left as is: the apps-ui warning (an unused require('webpack') in apps/ui/webpack.config.js), and the core and vite warnings (no-this-alias, and "Unused eslint-disable directive" from ESLint 9's reportUnusedDisableDirectives).
Checking var → let/const
apps/automated runs only on a device, so a temporal dead zone (TDZ) error would only show up at runtime. The changes were checked for this:
- ESLint's
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. - That still leaves one gap: a hoisted function declaration, or a callback passed to a call, that reads the binding and runs before the declaration. Every converted binding (1536 autofixed and 362 by hand in apps-automated, 171 in apps-ui) was checked with the TypeScript AST for references that could run before the declaration. A reference counts as safe only when it sits inside a function value that cannot be invoked before the declaration. None were found. The 22 hand-converted bindings with earlier references (for example
_createButtonFunc, used by theexport const test... = functionbodies above it) are all read only inside test functions, and those run after the module has loaded. - Exported
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 var semantics 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.- Kept as
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-checks reported that the app generator imports @angular-devkit/schematics but package.json doesn't declare it, and that tslib is declared but unused (importHelpers is off). @angular-devkit/schematics is now declared as ^18.2.21, the installed version, and tslib is removed. The root package.json and the lockfile are unchanged: the package arrives transitively through @nstudio/focus.
Formatting
The pre-commit lint-staged hook 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 --check passes 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-24 after npm ci. Everything ran with --skip-nx-cache.
| Check | Baseline | This PR |
|---|---|---|
| lint (7 projects) | see the table above | see the table above |
tsc --noEmit for apps/automated, apps/ui, apps/toolbox |
826 / 400 / 130 errors (existing: unresolved platform modules and the like) | the same errors, compared as file + code + message with positions ignored |
tsc --noEmit for webpack5 (tsconfig.json, tsconfig.lib.json) and workspace-plugin (tsconfig.lib.json, tsconfig.spec.json) |
0 | 0 |
core:test |
565 passed, 1 skipped | 565 passed, 1 skipped |
vite:test |
1929 passed | 1929 passed |
webpack5:test |
16 failed / 65 passed | the same 16 failed / 65 passed |
workspace-plugin:test |
no tests | no tests |
nx run-many -t build -p core,webpack5,vite |
pass | pass |
workspace-plugin:build |
pass | |
prettier --check (changed files) |
pass |
The apps/automated device suite wasn't run locally. The apps/automated/ios and apps/automated/android workflows run on this PR.
Notes
- workspace-plugin's only generator calls
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.
nx-cloud
Bot
commented
Nov 25, 2026
·
edited
Loading
Copy link Copy Markdown
|
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 |
pkg-pr-new
Bot
commented
Nov 25, 2026
·
edited
Loading
Copy link Copy Markdown
commit: |
f824d5b to
9e36e46
Compare
November 28, 2026 00:17 NathanWalker force-pushed the chore/lint-nx24-violations branch from
9e36e46 to
c0bdaa3
Compare
November 28, 2026 00:30 Base automatically changed from chore/nx-24 to main November 28, 2026 00:33 NathanWalker added 11 commits November 27, 2026 16:33
fix(workspace-plugin): declare dependencies
6a189f0
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.
build(lint): exempt @nativescript/core from the lazy-loaded library c...
846bf9d
...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.
style(webpack5): apply eslint autofixes
5fca199
prefer-const only.
style(apps): apply eslint autofixes to toolbox
6f5acac
prefer-const, plus one function-local no-var.
style(apps): apply eslint autofixes to ui
ab87787
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.
style(apps): apply eslint autofixes to automated
e7269d1
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.
build(lint): allow the triple-slash reference in apps/automated/refer...
3b5ddc8
...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.
fix(apps): resolve the lint errors that autofix leaves in the test apps
658e17b
- 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.
style(vite): fix the remaining lint errors
2c40dcf
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.
style: fix lint errors in code added since the lint sweep
bf53b38
Covers the typed-array body tests and the fragment TransitionListener that landed on main after the initial pass.
build(lint): ignore native platform build output in apps
93a4ed1
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
c0bdaa3 to
93a4ed1
Compare
November 28, 2026 00:33 NathanWalker merged commit
7aea47d
into
main
Nov 28, 2026
13 checks passed
NathanWalker
deleted the
chore/lint-nx24-violations
branch
November 28, 2026 00:37
NathanWalker
mentioned this pull request
Nov 28, 2026
feat(core): let style converters preserve CSS math
#11668
Open
3 tasks done
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment