Skip to content

Commit

Permalink
fix: fix illegal decorator check (#6723)
Browse files Browse the repository at this point in the history
* Fix illegal decorator check

* Fix

* Fix scope-manager tests

* Fix member-ordering.test.ts

* Fix no-unused-vars.test.ts

* Fix explicit-member-accessibility.test.ts

* Fix member-ordering-alphabetically-order.test.ts

* Linting

* Don't check setter getters

* Implement `nodeCanBeDecorated`

* Fix comment

* Fix type

* Revert

* Fix

* Use `ts.hasAmbientModifier`

* Revert "Use `ts.hasAmbientModifier`"

This reverts commit 04e3b73.

* refactor: use `getModifiers` and `getDecorators`

* Remove stub hasAmbientModifier

---------

Co-authored-by: Josh Goldberg <git@joshuakgoldberg.com>
  • Loading branch information
fisker and JoshuaKGoldberg committed Jun 17, 2023
1 parent 89b14f2 commit c456f8c
Show file tree
Hide file tree
Showing 29 changed files with 283 additions and 97 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions packages/ast-spec/tests/fixtures-with-differences-errors.shot

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -1835,7 +1835,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -1861,7 +1861,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -1882,7 +1882,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -1903,7 +1903,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand Down Expand Up @@ -1931,7 +1931,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -1952,7 +1952,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -1973,7 +1973,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand Down Expand Up @@ -2001,7 +2001,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -2022,7 +2022,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -2043,7 +2043,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand Down Expand Up @@ -2071,7 +2071,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -2092,7 +2092,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -2113,7 +2113,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand Down Expand Up @@ -2141,7 +2141,7 @@ class DecoratedClass {
public get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -2162,7 +2162,7 @@ class DecoratedClass {
private get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -2183,7 +2183,7 @@ class DecoratedClass {
protected get y() {
return this.x;
}
@foo @bar() set y(@foo @bar() value: x) {
@foo @bar() set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand Down Expand Up @@ -2211,7 +2211,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() public set y(@foo @bar() value: x) {
@foo @bar() public set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -2232,7 +2232,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() private set y(@foo @bar() value: x) {
@foo @bar() private set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand All @@ -2253,7 +2253,7 @@ class DecoratedClass {
get y() {
return this.x;
}
@foo @bar() protected set y(@foo @bar() value: x) {
@foo @bar() protected set z(@foo @bar() value: x) {
this.x = x;
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-plugin/tests/rules/member-ordering.test.ts
Expand Up @@ -1455,7 +1455,7 @@ class Foo {
code: `
class Foo {
constructor() {}
@Dec() public A(): void;
@Dec() public A(): void {}
@Dec() private B: string;
private C(): void;
private D: string;
Expand All @@ -1474,7 +1474,7 @@ class Foo {
{
code: `
class Foo {
@Dec() private A(): void;
@Dec() private A(): void {}
@Dec() private B: string;
constructor() {}
private C(): void;
Expand Down Expand Up @@ -1511,7 +1511,7 @@ class Foo {
code: `
class Foo {
public A(): string;
@Dec() public B(): string;
@Dec() public B(): string {}
public C(): string;
d: string;
Expand Down
Expand Up @@ -1982,7 +1982,7 @@ class Foo {
b2: string;
public c(): void;
@Dec() d(): void;
@Dec() d(): void {}
}
`,
options: [
Expand Down
Expand Up @@ -783,8 +783,10 @@ export interface Event<T> {
},
// https://github.com/typescript-eslint/typescript-eslint/issues/2369
`
export default function (@Optional() value = []) {
return value;
export class Test {
constructor(@Optional() value: number[] = []) {
console.log(value);
}
}
function Optional() {
Expand Down
Expand Up @@ -582,7 +582,7 @@ describe('References:', () => {
declare class C {
@deco
foo(): TypeC;
foo(): TypeC {};
}
`,
{
Expand Down
Expand Up @@ -5,5 +5,5 @@ class Foo {
return 1;
}
@decorator
set foo() {}
set bar(value) {}
}

0 comments on commit c456f8c

Please sign in to comment.