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 to ESLint 9.11 and typescript-eslint 8.8 #82

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.1
version: 9.12.0

- name: Install dependencies
run: pnpm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.1
version: 9.12.0

- name: Install dependencies
run: pnpm install --frozen-lockfile=true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.1
version: 9.12.0

- name: Install dependencies
run: pnpm install --frozen-lockfile=true
Expand Down
90 changes: 46 additions & 44 deletions dist/configs/itwinjs-recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ module.exports =
languageOptions: require("./utils/language-options"),
plugins: {
"@typescript-eslint": typescriptEslintPlugin,
"import": require("eslint-plugin-import"),
// "import": require("eslint-plugin-import"), // FIXME: Update coming this week
"prefer-arrow": require("eslint-plugin-prefer-arrow"),
"deprecation": require("eslint-plugin-deprecation"),
"@itwin": require("../plugin")
},
rules: {
Expand Down Expand Up @@ -43,24 +42,7 @@ module.exports =
}
],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/indent": [
"error",
2
],
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "comma",
"requireLast": false
}
}
],
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/naming-convention": [
"error",
Expand Down Expand Up @@ -170,6 +152,7 @@ module.exports =
}
],
"@typescript-eslint/return-await": "error",
"@typescript-eslint/no-deprecated": "error",
"@typescript-eslint/no-duplicate-type-constituents": "off",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-use-before-define": "off",
Expand All @@ -188,6 +171,7 @@ module.exports =
"varsIgnorePattern": "^_",
}
],
'@typescript-eslint/no-unused-expressions': 'off',
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
Expand All @@ -196,34 +180,52 @@ module.exports =
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/prefer-string-starts-ends-with": "off",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/quotes": [
"error",
"double",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/semi": [
"error",
"always"
],
"@typescript-eslint/space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}
],
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/typedef": "off",
"@typescript-eslint/unbound-method": "error",
"@typescript-eslint/unified-signatures": "error",
// FIXME: Do we want to migrate to @stylistic/eslint-plugin-ts?
Copy link
Member

Choose a reason for hiding this comment

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

i would lke to vote for no, and defer to using a formatter like prettier or biome or something else

// "@typescript-eslint/indent": [
// "error",
// 2
// ],
// "@typescript-eslint/member-delimiter-style": [
// "error",
// {
// "multiline": {
// "delimiter": "semi",
// "requireLast": true
// },
// "singleline": {
// "delimiter": "comma",
// "requireLast": false
// }
// }
// ],
// "@typescript-eslint/quotes": [
// "error",
// "double",
// {
// "avoidEscape": true,
// "allowTemplateLiterals": true
// }
// ],
// "@typescript-eslint/semi": [
// "error",
// "always"
// ],
// "@typescript-eslint/space-before-function-paren": [
// "error",
// {
// "anonymous": "always",
// "named": "never",
// "asyncArrow": "always"
// }
// ],
// "@typescript-eslint/type-annotation-spacing": "error",
"arrow-body-style": "off",
"arrow-parens": "error",
"brace-style": [
Expand All @@ -244,7 +246,7 @@ module.exports =
"off",
"multi-line"
],
"deprecation/deprecation": "error",
// "@typescript-eslint/no-deprecated": "error",
"dot-notation": "off",
"@typescript-eslint/dot-notation": "error",
"eol-last": "error",
Expand All @@ -262,9 +264,9 @@ module.exports =
"Undefined"
],
"id-match": "error",
"import/no-deprecated": "off", // using deprecation/deprecation instead
"import/no-duplicates": "off", // using no-duplicate-imports instead
"import/order": "off",
// FIXME "import/no-deprecated": "off", // using @typescript-eslint/no-deprecated instead
// FIXME "import/no-duplicates": "off", // using no-duplicate-imports instead
// FIXME "import/order": "off",
"indent": "off", // note you must disable the base rule as it can report incorrect errors
"max-classes-per-file": "off",
"max-len": "off",
Expand Down
30 changes: 15 additions & 15 deletions dist/rules/import-spacing.js
Copy link
Member

Choose a reason for hiding this comment

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

does this eslint rule seem silly?
should this be handled by prettier or some other formatter?

Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@ module.exports = {
docs: {
description: "Ensures proper spacing between import statement keywords.",
category: "TypeScript",
schema: [
{
type: "object",
additionalProperties: false,
properties: {
[OPTION_ALLOW_LINE_BREAKS_INSIDE_BRACKETS]: {
type: "boolean"
},
[OPTION_ALLOW_LINE_BREAKS]: {
type: "boolean"
},
}
}
]
},
messages: {
[Rules.ADD_SPACE_AFTER_IMPORT]: "Add space after 'import'",
Expand All @@ -60,7 +46,21 @@ module.exports = {
[Rules.ADD_SPACE_BEFORE_FROM]: "Add space before 'from'",
[Rules.TOO_MANY_SPACES_BEFORE_FROM]: "Too many spaces before 'from'",
[Rules.NO_LINE_BREAKS]: "Line breaks are not allowed in import declaration",
}
},
schema: [
{
type: "object",
additionalProperties: false,
properties: {
[OPTION_ALLOW_LINE_BREAKS_INSIDE_BRACKETS]: {
type: "boolean"
},
[OPTION_ALLOW_LINE_BREAKS]: {
type: "boolean"
},
}
}
],
},


Expand Down
28 changes: 14 additions & 14 deletions dist/rules/react-set-state-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ module.exports = {
docs: {
description: "Require the setState function to be called with function as the first argument and without 'this.props' nor 'this.state' access within the function.",
category: "TypeScript",
schema: [
{
type: "object",
additionalProperties: false,
properties: {
[OPTION_UPDATER_ONLY]: {
type: "boolean"
},
[OPTION_ALLOW_OBJECT]: {
type: "boolean"
}
},
schema: [
{
type: "object",
additionalProperties: false,
properties: {
[OPTION_UPDATER_ONLY]: {
type: "boolean"
},
[OPTION_ALLOW_OBJECT]: {
type: "boolean"
}
}
]
},
}
],
messages: {
failure: "Do not pass an object into setState. Use functional setState updater instead.",
failureUpdaterOnly: "Do not use callback parameter in setState. Use componentDidUpdate method instead (\"updater-only\" switch).",
failureAccessedMember: "Do not access 'this.{{accessedMember}}' in setState. Use arguments from callback function instead.",
}
},
},

create(context) {
Expand Down
12 changes: 6 additions & 6 deletions dist/rules/utils/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
function getParserServices(context) {
const errorMessage = "Could not find type information";
if (
!context.parserServices ||
!context.parserServices.program ||
!context.parserServices.esTreeNodeToTSNodeMap ||
!context.parserServices.tsNodeToESTreeNodeMap
!context.sourceCode.parserServices ||
!context.sourceCode.parserServices.program ||
!context.sourceCode.parserServices.esTreeNodeToTSNodeMap ||
!context.sourceCode.parserServices.tsNodeToESTreeNodeMap
) {
throw new Error(errorMessage);
}
const hasFullTypeInformation = context.parserServices.hasFullTypeInformation;
const hasFullTypeInformation = context.sourceCode.parserServices.hasFullTypeInformation;
if (hasFullTypeInformation === false) { // consider undefined == true for backwards compatibility
throw new Error(errorMessage);
}

return context.parserServices;
return context.sourceCode.parserServices;
}

module.exports = { getParserServices };
3 changes: 2 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"noImplicitAny": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"moduleResolution": "node"
"moduleResolution": "node16",
"module": "node16"
},
"include": ["**/*.js"]
}
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@
"url": "http://www.bentley.com"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "~7.0.1",
"@typescript-eslint/parser": "~7.0.1",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-import": "^2.29.1",
"@typescript-eslint/eslint-plugin": "~8.8.0",
"@typescript-eslint/parser": "~8.8.0",
"eslint-formatter-visualstudio": "^8.40.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jam3": "^0.2.3",
Copy link
Member

Choose a reason for hiding this comment

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

wonder if we should remove this, hasnt been touched in 5 yrs

"eslint-plugin-jsdoc": "^48.0.6",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-jsdoc": "^50.3.1",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^4.6.2",
"workspace-tools": "^0.36.4"
},
"peerDependencies": {
"eslint": "^8.56.0",
"eslint": "^9.11.1",
"typescript": "^3.7.0 || ^4.0.0 || ^5.0.0"
},
"devDependencies": {
"@types/eslint": "~8.56.2",
"@types/eslint": "~9.6.1",
"@types/node": "20.11.16",
"beachball": "^2.39.0",
"eslint": "^8.56.0",
"eslint": "^9.11.1",
"husky": "^9.0.11",
"mocha": "^10.3.0",
"typescript": "~5.3.3"
"typescript": "~5.6.2"
},
"engines": {
"node": "^18.18.0 || >=20.0.0"
Expand Down
Loading
Loading