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

feat: made BaseNode.parent non-optional #5252

Conversation

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Jun 26, 2022

BREAKING CHANGE:
changes the AST types in a non-backwards compatible way.


PR Checklist

Overview

Doesn't quite make BaseNode's parent property generic (a good next step?), but does make Program's property parent?: never.

I removed all checks like /if \(\w+\.parent/, /!\w+\.parent/, and /\w+\.parent ((&&)|(\|\|))/, then added back any that caused type checking complaints. Those were mostly from places that recursively went up the AST via node.parent.

@nx-cloud
Copy link

nx-cloud bot commented Jun 26, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3d65e74. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@netlify
Copy link

netlify bot commented Jun 26, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 4d55ee6
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/63587377879d070009a38c1e
😎 Deploy Preview https://deploy-preview-5252--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

* while traversing.
*/
// The parent node of the current node
// (added in @typescript-eslint/types as ESLint adds it while traversing)
Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to an inline // comment so the /** */ jsdoc comment doesn't risk getting attached to type.

@JoshuaKGoldberg JoshuaKGoldberg changed the title feat\!: made BaseNode.parent non-optional feat!: made BaseNode.parent non-optional Jun 26, 2022
export function getRange(
node: Pick<ts.Node, 'getEnd' | 'getStart'>,
ast: ts.SourceFile,
): [number, number] {
Copy link
Member Author

Choose a reason for hiding this comment

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

Program-typed values were getting passed in here. Having the node Pick out the only methods it needs stopped some type errors.

@@ -390,7 +387,7 @@ export class Converter {
params: typeParameters.map(typeParameter =>
this.convertType(typeParameter),
),
};
} as TSESTree.TSTypeParameterDeclaration;
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a reason this and the other node don't use this.createNode?

@codecov
Copy link

codecov bot commented Jun 26, 2022

Codecov Report

Merging #5252 (3d65e74) into v6 (9851338) will increase coverage by 0.03%.
The diff coverage is 97.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##               v6    #5252      +/-   ##
==========================================
+ Coverage   91.64%   91.67%   +0.03%     
==========================================
  Files         358      358              
  Lines       12237    12232       -5     
  Branches     3591     3585       -6     
==========================================
  Hits        11214    11214              
+ Misses        721      719       -2     
+ Partials      302      299       -3     
Flag Coverage Δ
unittest 91.67% <97.50%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...int-plugin/src/rules/consistent-type-assertions.ts 88.88% <ø> (ø)
packages/eslint-plugin/src/rules/indent.ts 92.85% <ø> (ø)
...ackages/eslint-plugin/src/rules/no-explicit-any.ts 96.42% <ø> (ø)
packages/eslint-plugin/src/rules/no-redeclare.ts 91.89% <ø> (ø)
...plugin/src/rules/no-redundant-type-constituents.ts 93.89% <ø> (ø)
.../eslint-plugin/src/rules/no-useless-constructor.ts 94.73% <ø> (ø)
...ackages/eslint-plugin/src/rules/prefer-as-const.ts 100.00% <ø> (ø)
...ckages/scope-manager/src/referencer/VisitorBase.ts 88.23% <50.00%> (ø)
packages/eslint-plugin/src/rules/array-type.ts 97.14% <100.00%> (ø)
...lugin/src/rules/consistent-generic-constructors.ts 94.87% <100.00%> (ø)
... and 32 more

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review June 26, 2022 00:51
@bradzacher bradzacher added breaking change This change will require a new major version to be released AST PRs and Issues about the AST structure labels Jul 2, 2022
@bradzacher bradzacher added this to the 6.0.0 milestone Jul 2, 2022
@bradzacher bradzacher changed the title feat!: made BaseNode.parent non-optional feat: made BaseNode.parent non-optional Jul 2, 2022
Andarist and others added 2 commits October 25, 2022 19:59
…pescript-eslint#5036)

* refactor(utils)!: removed `TRuleListener` generic from the `createRule`

* refactor!: removed `TRuleListener` generic from the `CLIEngine` and `RuleCreateFunction`

* chore: document and refactor 'extra' to 'parserSettings' (typescript-eslint#5834)

* chore(website): fix renamed Sponsorship docs link (typescript-eslint#5882)

* docs: Mention wide globs performance implications in monorepos docs and parser README (typescript-eslint#5864)

* docs: Mention wide globs performance implications in monorepos docs and parser readme

* Update docs/linting/typed-linting/MONOREPOS.md

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
Co-authored-by: Adnan Hashmi <56730784+adnanhashmi09@users.noreply.github.com>
…ipt-eslint#3076)

* feat: update TSImportType node

* fix: update visitor keys

* chore: document and refactor 'extra' to 'parserSettings' (typescript-eslint#5834)

* chore(website): fix renamed Sponsorship docs link (typescript-eslint#5882)

* docs: Mention wide globs performance implications in monorepos docs and parser README (typescript-eslint#5864)

* docs: Mention wide globs performance implications in monorepos docs and parser readme

* Update docs/linting/typed-linting/MONOREPOS.md

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
Co-authored-by: Adnan Hashmi <56730784+adnanhashmi09@users.noreply.github.com>
@bradzacher bradzacher changed the base branch from main to v6 October 26, 2022 01:40
JoshuaKGoldberg and others added 5 commits October 25, 2022 23:12
* feat(scope-manager): ignore ECMA version

* chore: document and refactor 'extra' to 'parserSettings' (typescript-eslint#5834)

* chore(website): fix renamed Sponsorship docs link (typescript-eslint#5882)

* Remove much more

* Fix WebLinter lint

* docs: Mention wide globs performance implications in monorepos docs and parser README (typescript-eslint#5864)

* docs: Mention wide globs performance implications in monorepos docs and parser readme

* Update docs/linting/typed-linting/MONOREPOS.md

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>

* chore: add auto-canary release for v6 (typescript-eslint#5883)

Co-authored-by: Adnan Hashmi <56730784+adnanhashmi09@users.noreply.github.com>
…TSInterfaceDeclaration and TSModuleDeclaration (typescript-eslint#4863)

* chore: remove invalid properties from ast nodes

* chore: remove invalid code in scope-manager and typescript-estree

* chore: re-write snapshots that were using invalid properties

* feat: remove modifiers union from ast types

Co-authored-by: Juan García <juank1809@gmail.com>
Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
* chore(utils)\!: remove (ts-)eslint-scope types

* Remove eslint-scope dep

* More file deletions
# Conflicts:
#	packages/eslint-plugin/src/rules/prefer-nullish-coalescing.ts
#	packages/utils/package.json
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

keanubeautiful

@JoshuaKGoldberg JoshuaKGoldberg merged commit a4768f3 into typescript-eslint:v6 Nov 25, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2022
@JoshuaKGoldberg JoshuaKGoldberg deleted the base-node-parent-non-optional branch March 8, 2023 22:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AST PRs and Issues about the AST structure breaking change This change will require a new major version to be released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reworking the parent property on AST Nodes
5 participants