Skip to content
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

fix(utils): add new properties since eslint 8.40.0 #7460

Merged
merged 3 commits into from
Aug 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/utils/src/ts-eslint/Rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,42 @@ interface RuleContext<
* Returns the current working directory passed to Linter.
* It is a path to a directory that should be considered as the current working directory.
* @since 6.6.0
* @deprecated Use {@link `cwd`} instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably want to remove these @deprecated tags.
most plugins will support ESLint v7 and v8 - they're not limited to 8.40.0
this means that trying to direct consumers to use these new APIs is an impossible state as they have to do things like context.cwd ?? context.getCwd() - which is just worse code than context.getCwd().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are 100% right - shall I open a new PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that makes sense.

@so1ve if you want to get another PR to typescript-eslint under your belt 😄 we can merge it any time before Monday midday EST. I'll set a reminder to send one in if one hasn't yet been by then.

*/
getCwd(): string;

/**
* The current working directory passed to Linter.
* It is a path to a directory that should be considered as the current working directory.
* @since 8.40.0
*/
cwd: string;

/**
* Returns the filename associated with the source.
* @deprecated Use {@link `filename`} instead.
*/
getFilename(): string;

/**
* The filename associated with the source.
* @since 8.40.0
*/
filename: string;

/**
* Returns the full path of the file on disk without any code block information (unlike `getFilename()`).
* @since 7.28.0
* @deprecated Use {@link `physicalFilename`} instead.
*/
getPhysicalFilename?(): string;

/**
* The full path of the file on disk without any code block information (unlike `filename`).
* @since 8.40.0
*/
physicalFilename?: string;

/**
* Returns the scope of the currently-traversed node.
* This information can be used track references to variables.
Expand All @@ -243,9 +265,17 @@ interface RuleContext<
/**
* Returns a SourceCode object that you can use to work with the source that
* was passed to ESLint.
* @deprecated Use {@link `sourceCode`} instead.
*/
getSourceCode(): Readonly<SourceCode>;

/**
* A SourceCode object that you can use to work with the source that
* was passed to ESLint.
* @since 8.40.0
*/
sourceCode: Readonly<SourceCode>;

/**
* Marks a variable with the given name in the current scope as used.
* This affects the no-unused-vars rule.
Expand Down