Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(typescript-estree): disallowusing as the variable keyword forfor..in loops#7649

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

Solo-steven
Copy link
Contributor

@Solo-stevenSolo-steven commentedSep 15, 2023
edited
Loading

PR Checklist

Overview

fix issue#7555 by check TypeScriptnodeflag, one problem is I not sure I add test case in correct file, if there are some wrong, please tell me, thanks ~

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@Solo-steven!

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 onhttps://opencollective.com/typescript-eslint.

@netlify
Copy link

netlifybot commentedSep 15, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit908aea3
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/65a05b55499c920008cd9650
😎 Deploy Previewhttps://deploy-preview-7649--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98 (🟢 up 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to yourNetlify site configuration.

@nx-cloud
Copy link

nx-cloudbot commentedSep 15, 2023
edited
Loading

☁️ Nx Cloud Report

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

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 19 targets

Sent with 💌 fromNxCloud.

@Solo-steven
Copy link
ContributorAuthor

Solo-steven commentedSep 15, 2023
edited
Loading

The reason that the CI job failed seems because OOM ( out of memory ), local linter result is pass, and since I only changed thetypescript-estree package, and the CI log shows that this package is passing linter, I belive re-run the CI pipeline should be ok ~ 😄


Screenshot 2023-09-15 at 5 33 26 PM

Copy link
Member

@Josh-CenaJosh-Cena left a comment
edited
Loading

Choose a reason for hiding this comment

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

The only thing forbidden isfor (using x in y), because in this casex is statically known to be non-disposable (it can only be string/symbol), so this is likely a mistake. For all other constructs,x can actually be a disposable, and the grammar allowsusing.

expect(() => instance.convertProgram()).toThrow();
});
it('using should be forbidden in for of statement ', () => {
const ast = convertCode('for(using foo of {});');
Copy link
Member

Choose a reason for hiding this comment

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

This is valid code.

expect(() => instance.convertProgram()).toThrow();
});
it('using should be forbidden in for statement ', () => {
const ast = convertCode('for(using i; i <= 0 ; ++i);');
Copy link
Member

Choose a reason for hiding this comment

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

So is this.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelOct 10, 2023
@JoshuaKGoldberg
Copy link
Member

👋 Hey@Solo-steven! Just checking in, is this still something you have time for? No worries if not - I just don't want to leave it hanging. Thanks!

@JoshuaKGoldbergJoshuaKGoldberg added the stalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period labelOct 17, 2023
@Solo-steven
Copy link
ContributorAuthor

👋 Hey@Solo-steven! Just checking in, is this still something you have time for? No worries if not - I just don't want to leave it hanging. Thanks!

Hi@JoshuaKGoldberg , sorry for the delay, I am missing this issue from my schedule, I change the test case and only disallow using whenusing is in for-of statement, and thanks@Josh-Cena 's check ~

@JoshuaKGoldberg
Copy link
Member

Okie dokie, when you're ready for it to be re-reviewed you canre-request a review.

Solo-steven reacted with thumbs up emoji

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelOct 21, 2023
@bradzacherbradzacher added bugSomething isn't working and removed stalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period labelsNov 10, 2023
@bradzacherbradzacher changed the titlefeat(typescript-estree): check for init not useusing keywordfix(typescript-estree): disallow using as the variable keyword forfor..in loopsNov 10, 2023
Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

thanks for your work on this! sorry for taking so long to get back to this.

Comment on lines 3464 to 3470
if (
!(
initializer.flags & ts.NodeFlags.Const ||
initializer.flags & ts.NodeFlags.Let ||
initializer.flags === ts.NodeFlags.None
)
) {
Copy link
Member

Choose a reason for hiding this comment

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

instead of checking for it "not being one of the valid states", instead can we just check for the one state we want to error on -(initializer.flags & ts.NodeFlags.Using) !== 0

) {
this.#throwError(
initializer,
" The left-hand side of a 'for...in' statement cannot be a 'using' declaration.",
Copy link
Member

Choose a reason for hiding this comment

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

nit remove the space

Suggested change
"The left-hand side of a 'for...in' statement cannot be a 'using' declaration.",
"The left-hand side of a 'for...in' statement cannot be a 'using' declaration.",

Comment on lines 364 to 372
describe('using should be forbidden in for-related initializer ', () => {
it('using should be forbidden in for in statement ', () => {
const ast = convertCode('for(using foo in {});');

const instance = new Converter(ast);

expect(() => instance.convertProgram()).toThrow();
});
});
Copy link
Member

Choose a reason for hiding this comment

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

We don't put AST tests in this location - this is more for testing our infra.
Instead we place our AST tests in theast-spec package alongside the AST declarations.

We haven't written proper docs for this yet (sorry!) but the steps for doing this is as follows:

  1. withinthis folder create a folder calledfixtures.
  2. withinfixtures create a_error_ folder
  3. within_error_ create a folder with a name for your case - for example maybeusing-initializer?
  4. within that folder, create a file calledfixture.ts
  5. within that file add your test code (egfor(using foo in {});)
  6. cd packages/ast-spec && yarn test to run the fixture tests and generate the necessary snapshots.

@bradzacherbradzacher added the awaiting responseIssues waiting for a reply from the OP or another party labelNov 10, 2023
@Josh-Cena
Copy link
Member

Hi@Solo-steven, do you have time to take a look at the review?

@Solo-steven
Copy link
ContributorAuthor

Hi@Solo-steven, do you have time to take a look at the review?

Hi@Josh-Cena Sorry about the late response, I am kind of busy this month, but I will fix this PR this weekend! thanks for your reminder ~

Josh-Cena reacted with thumbs up emoji

@JoshuaKGoldberg
Copy link
Member

👋 checking in again@Solo-steven - by "this month" do you mean January?

No worries if you're busy, just checking in!

@JoshuaKGoldbergJoshuaKGoldberg added the stalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period labelJan 8, 2024
…e test case to ast-spec* shorten syntax check for using keyword in for-in statement.* move test file to ast-spec.
@Solo-steven
Copy link
ContributorAuthor

I@JoshuaKGoldberg sorry about being so late, i pushed a new commit to fix the above problem, thanks for your patience and comment on this PR ~

JoshuaKGoldberg reacted with heart emoji

@JoshuaKGoldberg
Copy link
Member

Ok great, thanks!

Tip: if you ever want us to take another look, re-requesting review through the GitHub UI will auto-remove theawaiting response label. Nice little automation we set up 😄

@JoshuaKGoldbergJoshuaKGoldberg removed awaiting responseIssues waiting for a reply from the OP or another party stalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period labelsJan 11, 2024
@bradzacherbradzacher changed the titlefix(typescript-estree): disallow using as the variable keyword forfor..in loopsfix(typescript-estree): disallowusing as the variable keyword forfor..in loopsJan 11, 2024
bradzacher
bradzacher previously approved these changesJan 11, 2024
Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

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

this LGTM - thanks for adding this in!

@bradzacherbradzacher merged commit7e75e84 intotypescript-eslint:mainJan 12, 2024
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJan 20, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@bradzacherbradzacherbradzacher left review comments

@Josh-CenaJosh-CenaAwaiting requested review from Josh-Cena

Assignees
No one assigned
Labels
bugSomething isn't working
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bug:for (using foo in {}); should be invalid
4 participants
@Solo-steven@JoshuaKGoldberg@Josh-Cena@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp