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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build(deps): Bump @typescript-eslint/typescript-estree from 3.10.1 to 4.0.1 #9119

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Sep 1, 2020

Bumps @typescript-eslint/typescript-estree from 3.10.1 to 4.0.1.

Release notes

Sourced from @typescript-eslint/typescript-estree's releases.

v4.0.1

4.0.1 (2020-08-31)

Bug Fixes

v4.0.0

4.0.0 (2020-08-31)

This release comes just a few months after the v3 release due to the much faster than expected turnaround on optional chaining by ESTree. Read on for more details!

Summary of Changes

Breaking:

  • feat: support new ESTree optional chaining representation (#2308) (a4bd2a815447867132ce1f6dda574e608834b794)
  • feat: consume new scope analysis package (#2039) (abb0617e7cda636064193c65c73f8f8c08d8cb56)
  • feat(eslint-plugin): [ban-ts-comment] change default for ts-expect-error to allow-with-description (#2351) (ef85b7b92cf7b83e708bc85b58baca295955d5c8)
  • feat(eslint-plugin): [typedef] remove all default options (#2352) (13bd4dd11fc478a18a70e9e71853f099f0833330)
  • fix: correct decorator traversal for AssignmentPattern (#2375) (5ab473c07d43da70ddf8827efc8678c376fb15ab)
  • feat(eslint-plugin): [no-unnecessary-condition][strict-boolean-expressions] add option to make the rules error on files without strictNullChecks turned on (#2345) (ee5b194e6cb813e8aed0f2889b51d12a2b6964e4)
  • feat(typescript-estree): switch to globby (#2418) (789c439a8a80d1c3dc5d6c7ca4c5ae4d1d889a5b)

Non-Breaking:

  • feat(eslint-plugin): add consistent-type-imports rule (#2367) (ba9295b774765c293c94c5e82c26804ded25180d)
  • feat: add downlevel-dts to all packages with type declarations (a25718358e2c198e387a79d7f175baaa951ad547)

Breaking Changes

AST Changes

Support official ESTree optional chaining syntax (#2204)

When TS 3.7 released with optional chaining in November 2019, the feature was still a Stage-3 TC39 spec. This meant that ESTree[1] did not yet have an official AST representation defined, as they only officially support Stage-4 specs.

This meant that we either had to block on TS 3.7 support, unofficially support optional chaining, or find an interim representation to use. As we had no clear timeframe around which both optional chaining would move to Stage-4, and when the ESTree AST for it would be defined, we decided the first two options were sub-optimal, and instead chose to the existing babel-eslint AST representation. This representation has been in the ecosystem for a while and was supported by a variety of plugins.

Recently, ESTree agreed upon and merged an AST for optional chaining, which is vastly different to babel-eslint's representation. ESLint and their parser espree have already implemented and released support for this new AST as of ESLint v7.5.0.

In order to correct course to match the future of the ecosystem, we've update our AST to match the new, official representation.

This means a few things right now:

  1. The ESLint core rules will have complete support for optional chaining, without need for extension rules 馃帀
  2. Users might have to wait for plugins outside this project to update their logic to support this new AST.
Changelog

Sourced from @typescript-eslint/typescript-estree's changelog.

4.0.1 (2020-08-31)

Note: Version bump only for package @typescript-eslint/typescript-estree

4.0.0 (2020-08-31)

Bug Fixes

  • correct decorator traversal for AssignmentPattern (#2375) (d738fa4)
  • typescript-estree: correct ChainExpression interaction with parentheses and non-nulls (#2380) (762bc99)

Features

BREAKING CHANGES

  • typescript-estree: - removes the ability to supply a RegExp to projectFolderIgnoreList, and changes the meaning of the string value from a regex to a glob.
    • Removed decorators property from several Nodes that could never semantically have them (FunctionDeclaration, TSEnumDeclaration, and TSInterfaceDeclaration)
  • Removed AST_NODE_TYPES.Import. This is a minor breaking change as the node type that used this was removed ages ago.
Commits
  • 46ad4d0 chore: publish v4.0.1
  • c51e3f0 chore: publish v4.0.0
  • c3a6c2a chore: add downlevel-dts to all packages with type declarations
  • ac0defc chore: update dependencies
  • 3a7ec9b feat(typescript-estree): switch to globby (#2418)
  • 762bc99 fix(typescript-estree): correct ChainExpression interaction with parentheses ...
  • d738fa4 fix: correct decorator traversal for AssignmentPattern (#2375)
  • e9d2ab6 feat: support ESTree optional chaining representation (#2308)
  • See full diff in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@dependabot dependabot bot added javascript Pull requests that update Javascript code scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency labels Sep 1, 2020
@github-actions
Copy link

github-actions bot commented Sep 1, 2020

Size Change: +48 kB (0%)

Total Size: 9.13 MB

Filename Size Change
dist/bin-prettier.js 423 kB -1 B
dist/doc.js 118 kB -1 B
dist/index.js 1.59 MB -1 B
dist/parser-babel.js 296 kB +295 B (0%)
dist/parser-flow.js 1.88 MB +295 B (0%)
dist/parser-html.js 157 kB -1 B
dist/parser-markdown.js 174 kB -1 B
dist/parser-postcss.js 261 kB -1 B
dist/parser-typescript.js 3.04 MB +47.4 kB (1%)
dist/standalone.js 481 kB -1 B
鈩癸笍 View Unchanged
Filename Size Change
dist/parser-angular.js 49.6 kB 0 B
dist/parser-glimmer.js 168 kB 0 B
dist/parser-graphql.js 54.7 kB 0 B
dist/parser-yaml.js 144 kB 0 B
dist/third-party.js 292 kB 0 B

compressed-size-action

@sosukesuzuki sosukesuzuki self-assigned this Sep 1, 2020
@fisker
Copy link
Sponsor Member

fisker commented Sep 1, 2020

@sosukesuzuki You want work on this? You may want use this logic https://github.com/prettier/prettier/pull/9000/files#diff-2adb5e4d6193c992403ff12002873a90R141

@sosukesuzuki
Copy link
Member

sosukesuzuki commented Sep 1, 2020

transformation of ChainExpression seems to work fine. However, our tests fail because typescript-eslint 4.0 removes decorators from the node that TS doesn't support decorators.

https://github.com/typescript-eslint/typescript-eslint/releases/tag/v4.0.0

Remove decorators from nodes that TS doesn't support decorators on (typescript-eslint/typescript-eslint#2375)
Previously, our parser would parse decorators and include them in the AST for FunctionDeclarations, EnumDeclarations and InterfaceDeclarations. This was originally done because the TypeScript parser treats these as syntactically valid for various reasons (the TS parser is incredibly permissive in what it allows!).
However, it's semantically invalid to have decorators for these nodes, and TypeScript will throw a semantic compile-time error. Whilst you can ignore this error with an ignore comment, TypeScript will ignore the decorator completely in the compiled output.
Additionally, babel's TypeScript parser will throw a parser error in these cases.
With this version, the parser will no longer include the decorators property for the mentioned nodes.
Note that the parser will not error - it will just silently ignore the invalid decorators.

@sosukesuzuki
Copy link
Member

If we merge this as is, #4552 will reoccur.

Comment on lines +205 to +207
} else if (node.type === "TSNonNullExpression") {
node.expression = transformChainExpression(node.expression);
}
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I'm not familiar with typescript, but is it possible to have other types inside ChainExpression?

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

I'm wondering is this a mistake in parser? ChainExpression should be the root of optional chaining.

Shouldn't it be TSNonNullExpression > ChainExpression?

Copy link
Sponsor Member

@fisker fisker Sep 1, 2020

Choose a reason for hiding this comment

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

@bradzacher

What should this c?.d! be? The estree says

The ChainExpression node contains one or more ChainElement nodes that are optional:true.

https://github.com/estree/estree/blob/master/es2020.md#chainexpression

But in this case TSNonNullExpression is not ChainElement.

I'm not familiar with typescript, is this c?.d! mean d is non-null, and (c?.d)! mean c.d is non-null?

If it's correct, shouldn't TSNonNullExpression be the MemberExpression.property?


Update: as I see on prettier playground, (a?.b!).c (a?.b)!.c are the same, so I think the AST should be TSNonNullExpression > ChainExpression

Copy link

@bradzacher bradzacher Sep 1, 2020

Choose a reason for hiding this comment

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

I mirrored babel's (v7.11.3) implementation here.
This is the same AST they produce. typescript-eslint/typescript-eslint#2380


input code:

(a?.b!).c;
(a?.b)!.c;
`@babel/parser` @ `7.11.3`
{
  "type": "Program",
  "start": 0,
  "end": 21,
  "loc": {
    "start": {
      "line": 1,
      "column": 0
    },
    "end": {
      "line": 2,
      "column": 10
    }
  },
  "sourceType": "module",
  "interpreter": null,
  "body": [
    {
      "type": "ExpressionStatement",
      "start": 0,
      "end": 10,
      "loc": {
        "start": {
          "line": 1,
          "column": 0
        },
        "end": {
          "line": 1,
          "column": 10
        }
      },
      "expression": {
        "type": "MemberExpression",
        "start": 0,
        "end": 9,
        "loc": {
          "start": {
            "line": 1,
            "column": 0
          },
          "end": {
            "line": 1,
            "column": 9
          }
        },
        "object": {
          "type": "ChainExpression",
          "start": 1,
          "end": 6,
          "loc": {
            "start": {
              "line": 1,
              "column": 1
            },
            "end": {
              "line": 1,
              "column": 6
            }
          },
          "expression": {
            "type": "TSNonNullExpression",
            "start": 1,
            "end": 6,
            "loc": {
              "start": {
                "line": 1,
                "column": 1
              },
              "end": {
                "line": 1,
                "column": 6
              }
            },
            "expression": {
              "type": "MemberExpression",
              "start": 1,
              "end": 5,
              "loc": {
                "start": {
                  "line": 1,
                  "column": 1
                },
                "end": {
                  "line": 1,
                  "column": 5
                }
              },
              "object": {
                "type": "Identifier",
                "start": 1,
                "end": 2,
                "loc": {
                  "start": {
                    "line": 1,
                    "column": 1
                  },
                  "end": {
                    "line": 1,
                    "column": 2
                  },
                  "identifierName": "a"
                },
                "name": "a"
              },
              "computed": false,
              "property": {
                "type": "Identifier",
                "start": 4,
                "end": 5,
                "loc": {
                  "start": {
                    "line": 1,
                    "column": 4
                  },
                  "end": {
                    "line": 1,
                    "column": 5
                  },
                  "identifierName": "b"
                },
                "name": "b"
              },
              "optional": true
            }
          },
          "extra": {
            "parenthesized": true,
            "parenStart": 0
          }
        },
        "computed": false,
        "property": {
          "type": "Identifier",
          "start": 8,
          "end": 9,
          "loc": {
            "start": {
              "line": 1,
              "column": 8
            },
            "end": {
              "line": 1,
              "column": 9
            },
            "identifierName": "c"
          },
          "name": "c"
        },
        "optional": false
      }
    },
    {
      "type": "ExpressionStatement",
      "start": 11,
      "end": 21,
      "loc": {
        "start": {
          "line": 2,
          "column": 0
        },
        "end": {
          "line": 2,
          "column": 10
        }
      },
      "expression": {
        "type": "MemberExpression",
        "start": 11,
        "end": 20,
        "loc": {
          "start": {
            "line": 2,
            "column": 0
          },
          "end": {
            "line": 2,
            "column": 9
          }
        },
        "object": {
          "type": "TSNonNullExpression",
          "start": 11,
          "end": 18,
          "loc": {
            "start": {
              "line": 2,
              "column": 0
            },
            "end": {
              "line": 2,
              "column": 7
            }
          },
          "expression": {
            "type": "ChainExpression",
            "start": 12,
            "end": 16,
            "loc": {
              "start": {
                "line": 2,
                "column": 1
              },
              "end": {
                "line": 2,
                "column": 5
              }
            },
            "expression": {
              "type": "MemberExpression",
              "start": 12,
              "end": 16,
              "loc": {
                "start": {
                  "line": 2,
                  "column": 1
                },
                "end": {
                  "line": 2,
                  "column": 5
                }
              },
              "object": {
                "type": "Identifier",
                "start": 12,
                "end": 13,
                "loc": {
                  "start": {
                    "line": 2,
                    "column": 1
                  },
                  "end": {
                    "line": 2,
                    "column": 2
                  },
                  "identifierName": "a"
                },
                "name": "a"
              },
              "computed": false,
              "property": {
                "type": "Identifier",
                "start": 15,
                "end": 16,
                "loc": {
                  "start": {
                    "line": 2,
                    "column": 4
                  },
                  "end": {
                    "line": 2,
                    "column": 5
                  },
                  "identifierName": "b"
                },
                "name": "b"
              },
              "optional": true
            },
            "extra": {
              "parenthesized": true,
              "parenStart": 11
            }
          }
        },
        "computed": false,
        "property": {
          "type": "Identifier",
          "start": 19,
          "end": 20,
          "loc": {
            "start": {
              "line": 2,
              "column": 8
            },
            "end": {
              "line": 2,
              "column": 9
            },
            "identifierName": "c"
          },
          "name": "c"
        },
        "optional": false
      }
    }
  ]
}
`@typescript-eslint/typescript-estree` @ `4.0.1`
{
  "type": "Program",
  "body": [
    {
      "type": "ExpressionStatement",
      "expression": {
        "type": "MemberExpression",
        "object": {
          "type": "ChainExpression",
          "expression": {
            "type": "TSNonNullExpression",
            "expression": {
              "type": "MemberExpression",
              "object": {
                "type": "Identifier",
                "name": "a",
                "range": [
                  1,
                  2
                ]
              },
              "property": {
                "type": "Identifier",
                "name": "b",
                "range": [
                  4,
                  5
                ]
              },
              "computed": false,
              "optional": true,
              "range": [
                1,
                5
              ]
            },
            "range": [
              1,
              6
            ]
          },
          "range": [
            1,
            6
          ]
        },
        "property": {
          "type": "Identifier",
          "name": "c",
          "range": [
            8,
            9
          ]
        },
        "computed": false,
        "optional": false,
        "range": [
          0,
          9
        ]
      },
      "range": [
        0,
        10
      ]
    },
    {
      "type": "ExpressionStatement",
      "expression": {
        "type": "MemberExpression",
        "object": {
          "type": "TSNonNullExpression",
          "expression": {
            "type": "ChainExpression",
            "expression": {
              "type": "MemberExpression",
              "object": {
                "type": "Identifier",
                "name": "a",
                "range": [
                  12,
                  13
                ]
              },
              "property": {
                "type": "Identifier",
                "name": "b",
                "range": [
                  15,
                  16
                ]
              },
              "computed": false,
              "optional": true,
              "range": [
                12,
                16
              ]
            },
            "range": [
              12,
              16
            ]
          },
          "range": [
            11,
            18
          ]
        },
        "property": {
          "type": "Identifier",
          "name": "c",
          "range": [
            19,
            20
          ]
        },
        "computed": false,
        "optional": false,
        "range": [
          11,
          20
        ]
      },
      "range": [
        11,
        21
      ]
    }
  ],
  "sourceType": "script",
  "range": [
    0,
    21
  ]
}

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Thank you for the information, I'll take a deep look

@bradzacher
Copy link

If we merge this as is, #4552 will reoccur.

Hmm, when I wrote typescript-eslint/typescript-eslint#2375 I didn't know that this would cause problems for you guys.

I'm not sure what the best solution is here for this.
It's actually entirely possible for you guys to leverage the parser services here to get at the underlying TS AST and throw an exception, though it's definitely not a great solution.

Babel parser hard errors for this, but we don't - we don't error for any invalid code right now. I definitely want to, maybe in the next major? typescript-eslint/typescript-eslint#1852

@dependabot @github
Copy link
Contributor Author

dependabot bot commented on behalf of github Sep 8, 2020

A newer version of @typescript-eslint/typescript-estree exists, but since this PR has been edited by someone other than Dependabot I haven't updated it. You'll get a PR for the updated version as normal once this PR is merged.

@fisker
Copy link
Sponsor Member

fisker commented Sep 21, 2020

What do we do about this?

@bradzacher
Copy link

The parser services is an option if you want to do it properly and support it / error on it.

I wonder if it's okay just ignoring this case? It seems weird to have handling for a completely invalid state?

@sosukesuzuki
Copy link
Member

This PR is old so close for now. I'll reopen as an other PR.

@dependabot @github
Copy link
Contributor Author

dependabot bot commented on behalf of github Nov 9, 2020

OK, I won't notify you again about this release, but will get in touch when a new version is available.

If you change your mind, just re-open this PR and I'll resolve any conflicts on it.

@dependabot dependabot bot deleted the dependabot/npm_and_yarn/typescript-eslint/typescript-estree-4.0.1 branch November 9, 2020 02:18
@fisker fisker mentioned this pull request Nov 9, 2020
13 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript Pull requests that update Javascript code scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants