Skip to content

Commit

Permalink
Update to TypeScript 5.5 + ESLint 9.9 (#171)
Browse files Browse the repository at this point in the history
This PR updates TypeScript to v5.5.x and ESLint to 9.9.x. As part of the ESLint upgrade, several ESLing packages were dropped since they don't support the new flat config.

This PR is a prerequisite to evaluating if we can drop the requirement of `@babel/plugin-proposal-decorators` since native support for [decorators](https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#decorators) in TS was advanced to the stage 3 implementation.
  • Loading branch information
guyca authored Sep 5, 2024
1 parent 7301c2b commit a0b95b9
Show file tree
Hide file tree
Showing 118 changed files with 1,750 additions and 1,235 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.12.0
20.16.0
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
"estree",
"Middlewares",
"MVVM",
"plusplus",
"preconfigured",
"TSES",
"tseslint",
"unimported",
"unmagler",
"unsubscribers"
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-plugin-obsidian/.eslintignore

This file was deleted.

106 changes: 0 additions & 106 deletions packages/eslint-plugin-obsidian/.eslintrc.json

This file was deleted.

154 changes: 154 additions & 0 deletions packages/eslint-plugin-obsidian/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import stylistic from "@stylistic/eslint-plugin";
import eslintTs from "typescript-eslint";
import eslintJs from "@eslint/js";
import eslintJest from "eslint-plugin-jest";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";

export default eslintTs.config(
{
ignores: ["**/*.d.ts", "**/*.js"],
},
{
files: ["**/*.ts", "**/*.tsx"],
name: "EslintPluginObsidian",
languageOptions: {
globals: {
...globals.jest,
},
sourceType: "module",
parser: tsParser,
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
},
},
extends: [
eslintJs.configs.recommended,
...eslintTs.configs.recommendedTypeChecked,
eslintJest.configs['flat/recommended'],
stylistic.configs["recommended-flat"],
],
rules: {
"no-console": "off",
"no-empty-function": ["error", {
allow: ["constructors"],
}],

"no-multi-spaces": "error",

"no-multiple-empty-lines": ["error", {
max: 1,
}],

"@stylistic/max-len": ["error", {
code: 115,
comments: 200,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],

"@stylistic/no-extra-semi": "error",

"@stylistic/lines-between-class-members": ["error", "always", {
exceptAfterSingleLine: true,
}],

"import/extensions": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"no-useless-constructor": "off",
"@stylistic/member-delimiter-style": "error",
"import/no-unresolved": "off",
"class-methods-use-this": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["off"],
"no-restricted-syntax": "off",
"import/no-named-as-default": "off",
"@typescript-eslint/ban-types": ["off"],

// "import/no-extraneous-dependencies": ["error", {
// devDependencies: true,
// }],

"max-classes-per-file": ["off"],
curly: ["error", "multi-line"],
"@stylistic/semi": ["error", "always"],
"@stylistic/comma-dangle": ["error", "always-multiline"],
"@stylistic/function-call-argument-newline": ["error", "consistent"],
"@stylistic/function-paren-newline": ["error", "multiline-arguments"],

"@stylistic/object-curly-newline": ["error", {
ObjectExpression: {
multiline: true,
consistent: true,
},

ObjectPattern: {
multiline: true,
consistent: true,
},
}],

"@stylistic/no-whitespace-before-property": "error",

// "import-newlines/enforce": ["error", {
// items: 3,
// "max-len": 115,
// semi: false,
// }],

"no-plusplus": "off",
"@stylistic/no-trailing-spaces": "error",
"no-shadow": "off",

"@typescript-eslint/no-shadow": ["error", {
allow: ["Graph"],
}],

"arrow-body-style": ["off"],
"@stylistic/member-delimiter-style": ["error", {
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
},
"multilineDetection": "brackets"
}],
"@stylistic/quotes": ["error", "single", {
avoidEscape: true,
allowTemplateLiterals: true,
}],
"@typescript-eslint/no-base-to-string": "off",

"@typescript-eslint/lines-between-class-members": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-require-imports": ["error", {
allow: ["path"]
}],
"import/prefer-default-export": "off",
"@typescript-eslint/no-unused-vars": "off",
// "unused-imports/no-unused-imports": "error",

// "unused-imports/no-unused-vars": ["error", {
// vars: "all",
// varsIgnorePattern: "^_",
// args: "after-used",
// argsIgnorePattern: "^_",
// }],

"@typescript-eslint/ban-ts-comment": "off",
},
}
);
1 change: 1 addition & 0 deletions packages/eslint-plugin-obsidian/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const config = {
'tests'
],
testEnvironment: 'jsdom',
setupFiles: ['./jest.setup.js'],
};

module.exports = config;
5 changes: 5 additions & 0 deletions packages/eslint-plugin-obsidian/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// https://github.com/jsdom/jsdom/issues/3363#issuecomment-1221060809
// https://stackoverflow.com/questions/73607410/referenceerror-structuredclone-is-not-defined-using-jest-with-nodejs-typesc
global.structuredClone = val => {
return JSON.parse(JSON.stringify(val))
}
45 changes: 23 additions & 22 deletions packages/eslint-plugin-obsidian/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "eslint-plugin-obsidian",
"description": "ESLint rules for Obsidian",
"main": "dist/index.js",
"version": "2.10.2",
"version": "2.11.0-alpha.1",
"scripts": {
"build": "npx tsc --project tsconfig.prod.json",
"test": "npx jest",
"lint": "eslint src --ignore-pattern '*.d.ts' --ext .ts,.tsx,.js"
"lint": "eslint"
},
"author": "Orly Dadashev",
"files": [
Expand All @@ -15,13 +15,13 @@
"LICENSE"
],
"peerDependencies": {
"eslint": "8.x.x",
"eslint": "^9.9.0",
"eslint-plugin-obsidian": "*",
"react-obsidian": "2.x.x"
},
"dependencies": {
"@typescript-eslint/parser": "6.6.x",
"@typescript-eslint/utils": "6.6.x",
"@typescript-eslint/parser": "8.4.0",
"@typescript-eslint/utils": "8.4.0",
"lodash": "^4.17.21"
},
"devDependencies": {
Expand All @@ -33,24 +33,25 @@
"@babel/preset-react": "7.22.x",
"@babel/preset-typescript": "7.22.x",
"@babel/types": "7.24.x",
"@eslint/eslintrc": "^3.0.2",
"@eslint/js": "8.x.x",
"@stylistic/eslint-plugin": "^1.7.0",
"@types/eslint": "8.4.9",
"@types/node": "18.x.x",
"@typescript-eslint/eslint-plugin": "6.6.x",
"@typescript-eslint/rule-tester": "6.6.x",
"@typescript-eslint/types": "6.6.x",
"@typescript-eslint/typescript-estree": "6.6.x",
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.9.0",
"@stylistic/eslint-plugin": "^2.7.2",
"@types/eslint": "^9.6.1",
"@types/node": "20.16.x",
"@typescript-eslint/eslint-plugin": "^8.4.0",
"@typescript-eslint/rule-tester": "^8.4.0",
"@typescript-eslint/types": "^8.4.0",
"@typescript-eslint/typescript-estree": "^8.4.0",
"cross-env": "^7.0.3",
"eslint": "8.x.x",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-import-newlines": "^1.1.5",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-unused-imports": "3.1.x",
"jest": "29.5.x",
"jest-extended": "^4.0.0",
"typescript": "^4.5.4"
"eslint": "^9.9.1",
"eslint-plugin-jest": "^28.8.2",
"eslint-plugin-unused-imports": "^4.1.3",
"globals": "^15.9.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-extended": "^4.0.2",
"typescript": "^5.5.4"
},
"keywords": [
"react-obsidian",
Expand Down
Loading

0 comments on commit a0b95b9

Please sign in to comment.