Skip to content

Conversation

victorenator
Copy link
Contributor

@victorenator victorenator commented Oct 6, 2024

a.js:

class A {
  accessor b;
}

Current and expected behavior:

npx eslint a.js
a.js
  2:11  error  'b' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)
Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

a.js:

```js
class A {
  accessor b;
}
```

Current and expected behavior:

```bash
npx eslint a.js
```

```
a.js
  2:11  error  'b' is not defined  no-undef

✖ 1 problem (1 error, 0 warnings)
```
@babel-bot
Copy link
Collaborator

babel-bot commented Oct 6, 2024

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/58079

@JLHwung
Copy link
Contributor

JLHwung commented Oct 6, 2024

Can you add some new tests to eslint/babel-eslint-tests/test/integration/eslint/verify.js? They would be similar to what we have for class field declarations:

describe("field declarations", () => {
it("should not be undefined", () => {
verifyAndAssertMessages(
`
class C {
d = 1;
}
`,
{ "no-undef": 1 },
);
});
it("should not be unused", () => {
verifyAndAssertMessages(
`
export class C {
d = 1;
}
`,
{ "no-unused-vars": 1 },
);
});
it("no-use-before-define allows referencing the class in a field", () => {
verifyAndAssertMessages(
`
class C {
d = C.name;
}
`,
{ "no-use-before-define": 1 },
);
});
});

);
});

it("no-use-before-define allows referencing the class in a accessor", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
it("no-use-before-define allows referencing the class in a accessor", () => {
it("no-use-before-define allows referencing the class in an accessor", () => {

@JLHwung JLHwung requested a review from liuxingbaoyu October 12, 2024 02:48
Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

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

Thanks!

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: eslint labels Oct 12, 2024
@JLHwung JLHwung merged commit 33d705e into babel:main Oct 12, 2024
52 checks passed
@victorenator victorenator deleted the patch-1 branch October 22, 2024 19:01
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 22, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: eslint outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants