Skip to content

Commit

Permalink
WIP: Updating to ESLint 9.11 and typescript-eslint 8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
wgoehrig committed Oct 2, 2024
1 parent 779c4a1 commit 8a14ca3
Show file tree
Hide file tree
Showing 11 changed files with 2,513 additions and 1,704 deletions.
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?
// "@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
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",
"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

0 comments on commit 8a14ca3

Please sign in to comment.