-
Notifications
You must be signed in to change notification settings - Fork 626
[heft-lint-plugin] Add support for ESLint 9 #5219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…er/danade/UpdateEslint2
// | ||
// const { CONSTANT1, CONSTANT2 } = someNamespace.constants; | ||
// | ||
// Thus for now "property" is more like a variable than a class member. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per ECMAScript, the above examples are, in fact, values of type "Property" so this comment is weird.
|
||
// Genuine properties | ||
{ | ||
selectors: ['parameterProperty', 'accessor'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If parameterProperty
the deprecated constructor(public foo: string)
nonsense or destructured parameters, e.g. function ({ foo }: { foo: string })
?
import type * as TTypescript from 'typescript'; | ||
import type * as TEslint from 'eslint'; | ||
import path from 'node:path'; | ||
import { createHash, type Hash } from 'crypto'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { createHash, type Hash } from 'crypto'; | |
import { createHash, type Hash } from 'node:crypto'; |
import type * as TTypescript from 'typescript'; | ||
import type * as TEslint from 'eslint'; | ||
import path from 'node:path'; | ||
import { createHash, type Hash } from 'crypto'; | ||
import { performance } from 'perf_hooks'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { performance } from 'perf_hooks'; | |
import { performance } from 'node:perf_hooks'; |
let programs: TTypescript.Program[] | undefined; | ||
if (this.languageOptions?.parserOptions?.programs) { | ||
programs = this.languageOptions.parserOptions.programs; | ||
delete this.languageOptions.parserOptions.programs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set this to undefined
instead? The delete
operator is a guaranteed deopt of property accesses from the object, and JSON serialization ignores properties with a value of undefined
.
const eslintBaseConfiguration: any = await this._linter.calculateConfigForFile( | ||
this._linterConfigFilePath | ||
protected override async getCacheVersionAsync(): Promise<string> { | ||
return `${this._eslintPackageVersion.version}_${process.version}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the version of Node.js really relevant to the eslint rule evaluation?
// The eslint configuration object contains a toJSON() method that returns a serializable version of the | ||
// configuration. However, we are manually injecting the TypeScript program into the parserOptions, which | ||
// is not serializable. Patch the function to remove the program before returning the serializable version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we instead inject it using Object.defineProperty
and don't make it enumerable?
this._fixesPossible = | ||
this._fixesPossible || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this._fixesPossible = | |
this._fixesPossible || | |
this._fixesPossible ||= |
// if (message.source) { | ||
// physicalLocation.region ??= {}; | ||
// physicalLocation.region.snippet = { | ||
// text: message.source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is message.source
no longer a field?
const { defineConfig } = require('eslint/config'); | ||
const friendlyLocalsMixin = require('local-eslint-config/flat/mixins/friendly-locals'); | ||
|
||
module.exports = defineConfig([...friendlyLocalsMixin]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a purpose to duplicating the array or could we just pass it directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicating to allow for easy update in the future. Can be left as an array directly if we wanted to.
…er/danade/UpdateEslint2
…er/danade/UpdateEslint2
…er/danade/UpdateEslint2
Summary
NOTE: Once merged, a publish and bump of decoupled dependencies will be required to update the remaining projects. The new configs should be moved into the decoupled rig, which currently is the source for the configs for the
local-node-rig
configs.How it was tested
This PR.
Impacted documentation
Any ESLint-related docs will need to be updated to indicate support.