chore: Upgrade eslint to v9#7760
Conversation
…um are never nullish
Removed optional chaining before `.split()`; the `!isFree` branch guarantees `billing.description` exists
…ining: optional chaining should be on inside
…nullish coalescing operator
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7760 +/- ##
==========================================
- Coverage 75.39% 75.39% -0.01%
==========================================
Files 428 428
Lines 22540 22539 -1
Branches 5945 5944 -1
==========================================
- Hits 16994 16993 -1
Misses 5546 5546
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Re: the Trivy/SAST findings on this PRTL;DR - these are pre-existing vulnerabilities on This is an ESLint 8→9 migration; the only production/lockfile impact is dev-time lint tooling. None of the flagged packages (vite, serialize-javascript, uuid, jsonata, minimatch) were added or changed here. Details
Why is it flagging here? Resolution Alternatively, I can add a child PR based off this branch that squashes all/most of these (with Or - suggestions welcome :) FWIW, as stated in sprint planning, I am attempting to get a more healthy npm audit (that includes dev deps) as part of dependabot duties. ESLINT was an outstanding task that would smash a good handful of warnings and why it was approached first. |
This is correct.
This is correct. If you check all alerts for this branch, you'll see none were introduced there.
That's the best approach. |
cstns
left a comment
There was a problem hiding this comment.
well structured migration with thorough documentation.
the /* eslint-env browser */ lines in context.spec.js and team-channel.subscriber.spec.js were already redundant (the config covers test/unit/frontend/**). Could just delete them here instead of deferring, if you want
Wanted to keep the focus on migration (+ error fixes) Will address in follow up |
|
@ppawlowski This has been approved and auto merge is "on" but I will not be around to baby sit (and dont know what happens with regards trivy - will the PR merge or is there a tick box task to do)? |
|
Trivy is not a blocker for the auto-merge, but tests are, and they currently fail against changes in this PR. |
Description
As part of getting dependencies up to date (as best as possible / sensible), this is an outstanding task that has been on the backlog for some time. Upgrading to v9 (and flat file format) helps us het past some old dependencies and clear some vulns.
Overview
Migrates the package from ESLint 8 (
.eslintrc, eslintrc format) to ESLint 9 flat config (eslint.config.mjs). The Standard ruleset moves fromeslint-config-standardto its flat-config successor neostandard, and the Cypress and Vue plugins are brought up to their current majors.TLDR
I appreciate there is a lot of info below - i have tried to keep it readable / formatted as glanceable info - however it serves as a reference for the what and why!
The long and short is:
Dependency changes (
devDependencies)Upgraded
eslint^8.48.0^9.39.4eslint-plugin-cypress2.15.1^6.4.2eslint-plugin-vue^9.19.2^10.9.2eslint-plugin-no-only-tests^3.1.0^3.4.0Added
neostandard^0.13.0eslint-config-standard; bundles then,promise, and@stylisticrule sets@eslint/js^9.39.4js.configs.recommendedbaseeslint-plugin-import-x^4.17.1import-x/*); replaceseslint-plugin-importglobals^17.7.0node,browser,mocha, …)vue-eslint-parser^10.4.1eslint-plugin-vuev10 (was bundled in v9)Removed
eslint-config-standard^17.1.0neostandardeslint-plugin-import^2.28.1eslint-plugin-import-xeslint-plugin-n^16.0.2neostandardeslint-plugin-promise^6.1.1neostandard(
@typescript-eslint/parserand@typescript-eslint/eslint-pluginare unchanged and already flat-config compatible.)Config / script changes
.eslintrc→eslint.config.mjs- The flat config attempts to faithfully port the old rules, overrides, and per-file exceptions.eslint.config.mjs, so the explicit config path, globs, and ignore patterns are no longer needed:lint:eslint:eslint -c .eslintrc "forge/**/*.js" "frontend/**/*.js" "frontend/**/*.vue" "test/**/*.js" --ignore-pattern "frontend/dist/**"→eslint forge frontend testlint:fix: same simplification, with--fixLint errors fixed
Pre-existing code issues surfaced by the stricter ESLint 9 / neostandard rule set, fixed in this PR (all behaviour-preserving):
forge/comms/devices.jsno-object-constructor{}literal instead ofnew Object()however, for now, I have silenced the rule for this one item.forge/routes/api/search.jsno-constant-binary-expression?? 0guards -Array.lengthand its sum are never nullishfrontend/src/api/teamTypes.jsno-unsafe-optional-chaining.split(); the!isFreebranch guaranteesbilling.descriptionexistsfrontend/src/pages/admin/Teams.vueno-dupe-else-ifelse-ifbranchfrontend/src/pages/instance/Settings/Maintenance.vueno-constant-binary-expression,no-unsafe-optional-chaining??/ optional-chaining cleanupfrontend/src/pages/team/changeType.vueno-constant-binary-expression?? false-!expris always boolean, never nullishfrontend/src/services/post-message.service.ts@stylistic/block-spacing,@stylistic/object-curly-spacingDeferred to a follow-up PR
To keep this PR focused on the migration, two categories of findings are temporarily suppressed in
eslint.config.mjs(both taggedTODO(eslint-v9-follow-up)):eslint-disabledirectives - the rule-set change left inlineeslint-disablecomments that no longer match a reported problem (forn/no-process-exit,n/no-extraneous-import,n/no-unpublished-require,n/handle-callback-err,no-unused-vars,no-useless-return,no-template-curly-in-string,promise/no-callback-in-promise,vue/one-component-per-file). Silenced vialinterOptions.reportUnusedDisableDirectives: 'off'; the follow-up will delete the stale directives and re-enable the check.vue/no-required-prop-with-default- a new Vue 10 rule flagging a required prop that also declares a default. Rule disabled for now; the follow-up will fix the offending prop(s)./* eslint-env */comments - flat config no longer honours/* eslint-env */(the globals are already provided by the config'sfiles-scopedlanguageOptions.globals), so these emit anESLintEnvWarningon stderr and will become hard errors in ESLint v10. Two files remain (test/unit/frontend/stores/context.spec.js,test/unit/frontend/subscribers/team-channel.subscriber.spec.js); the follow-up will delete the now-redundant/* eslint-env browser */lines. No config change needed.Notes for reviewers
.tsfiles are now linted (the old glob-based script never included them); the Node-resolution rules (n/no-missing-import,n/file-extension-in-import, etc.) are disabled for frontend blocks since it's webpack-bundled, matching the intent of the original config.recommendedsets are stricter than the previous versions, so this PR surfaces additional lint findings intest/e2e/**and.vuefiles. Those are addressed separately.Related Issue(s)
closes #6458
Checklist
flowforge.yml?FlowFuse/helmto update ConfigMap TemplateFlowFuse/CloudProjectto update values for Staging/ProductionLabels
area:migrationlabel