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

Update TypeScript-related packages and rules #171

Merged
merged 5 commits into from
Aug 22, 2023
Merged

Conversation

sjinks
Copy link
Member

@sjinks sjinks commented Aug 21, 2023

  1. Add support for the 6.x series of @typescript-eslint (this adds support for TypeScript 5.1+)
  2. Update eslint-plugin-import to 2.28.1 (necessary for this)
  3. Update @babel/eslint-parser to 7.22.10

package.json Outdated
Comment on lines 37 to 38
"@typescript-eslint/eslint-plugin": "^5.55.0 || ^6.0.0",
"@typescript-eslint/parser": "^5.55.0 || ^6.0.0",
Copy link
Member

Choose a reason for hiding this comment

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

Why the ||? these aren't peerDeps, so they will resolve the left hand side of the operator and will be stuck there via package-lock. (In this case, @typescript-eslint/parser gets 5.62)

Copy link
Member Author

Choose a reason for hiding this comment

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

This was because of eslint-plugin-jest :-( It should usually resolve to the highest possible version.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to 6.0.0 and eslint-plugin-jest from 27.2.1 to 27.1.3.

package.json Outdated
@@ -32,13 +32,13 @@
},
"homepage": "https://github.com/Automattic/eslint-config-wpvip#readme",
"dependencies": {
"@babel/eslint-parser": "7.21.3",
"@babel/eslint-parser": "^7.22.10",
Copy link
Member

Choose a reason for hiding this comment

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

Can we stick to exact refs?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can, but we have copies of @babel/eslint-parser in our projects (say, in vip-cli). All babel-related packages are updated together, and we will end up having multiple copies of @babel/eslint-parser.

Copy link
Member

Choose a reason for hiding this comment

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

We can remove @babel/eslint-parser from VIP CLI, as well as any other peer dependencies leftover from older versions of this plugin. We now have a module resolution adapter that pulls dependencies from this project.

I have done this for other projects I've updated and it works very well. The only two dependencies needed when using this plugin are eslint and @automattic/eslint-plugin-wpvip.

https://github.com/Automattic/eslint-config-wpvip#configuration

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, but if we stick to the exact version, will it be safe to update other Babel-related packages? I would like to avoid publishing a new package version every time we update Babel.

Copy link
Member

Choose a reason for hiding this comment

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

If we align on major version (7, currently) then I have not seen any issues with minor version drift.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I have removed the caret.

Comment on lines +150 to +168
{
"column": 121,
"endColumn": 121,
"endLine": 45,
"fix": {
"range": [
894,
894,
],
"text": "
",
},
"line": 45,
"message": "Insert \`⏎\`",
"messageId": "insert",
"nodeType": null,
"ruleId": "prettier/prettier",
"severity": 2,
},
Copy link
Member Author

@sjinks sjinks Aug 22, 2023

Choose a reason for hiding this comment

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

Comment on lines +174 to +184
{
"column": 48,
"endColumn": 61,
"endLine": 1,
"line": 1,
"message": "'three' is defined but never used.",
"messageId": "unusedVar",
"nodeType": "Identifier",
"ruleId": "@typescript-eslint/no-unused-vars",
"severity": 2,
},
Copy link
Member Author

Choose a reason for hiding this comment

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

It looks like the @typescript-eslint/no-unused-vars rule now catches unused parameters as well.

export function add( one: number, two: number, three: String ): number {
	return one + two;
}

Comment on lines +185 to +202
{
"column": 55,
"endColumn": 61,
"endLine": 1,
"fix": {
"range": [
54,
60,
],
"text": "string",
},
"line": 1,
"message": "Don't use \`String\` as a type. Use string instead",
"messageId": "bannedTypeMessage",
"nodeType": "Identifier",
"ruleId": "@typescript-eslint/ban-types",
"severity": 2,
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +203 to +213
{
"column": 1,
"endColumn": 14,
"endLine": 5,
"line": 5,
"message": "Do not use "@ts-ignore" because it alters compilation errors.",
"messageId": "tsDirectiveComment",
"nodeType": "Line",
"ruleId": "@typescript-eslint/ban-ts-comment",
"severity": 2,
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines -171 to +230
"severity": 1,
"severity": 2,
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines +289 to +299
{
"column": 49,
"endColumn": 54,
"endLine": 29,
"line": 29,
"message": "'value' is defined but never used.",
"messageId": "unusedVar",
"nodeType": "Identifier",
"ruleId": "@typescript-eslint/no-unused-vars",
"severity": 2,
},
Copy link
Member Author

Choose a reason for hiding this comment

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

'@typescript-eslint/no-shadow': 'error',
'import/no-duplicates': 'error',
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -42,4 +42,4 @@ export function shadow() {

nonExistent();

// There is intentionally no new line at the end of this file to hit [eol-last](https://eslint.org/docs/rules/eol-last).
// There is intentionally no new line at the end of this file to hit [eol-last](https://eslint.org/docs/rules/eol-last).
Copy link
Member

Choose a reason for hiding this comment

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

thanks, this one keeps getting clobbered

Copy link
Member

@chriszarate chriszarate left a comment

Choose a reason for hiding this comment

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

Thanks!

@sjinks sjinks merged commit e611a8f into trunk Aug 22, 2023
4 checks passed
@sjinks sjinks deleted the update/typescript branch August 22, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants