Skip to content

Commit

Permalink
Merge pull request #1467 from authts/chore-2
Browse files Browse the repository at this point in the history
bump eslint to v9
  • Loading branch information
pamapa authored Jan 17, 2025
2 parents e8eb512 + 81b516c commit 537b1c3
Show file tree
Hide file tree
Showing 8 changed files with 2,079 additions and 2,233 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

75 changes: 0 additions & 75 deletions .eslintrc.yml

This file was deleted.

124 changes: 124 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import stylistic from "@stylistic/eslint-plugin";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import testingLibrary from "eslint-plugin-testing-library";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [{
ignores: ["**/node_modules/", "**/dist/", "**/lib/"],
}, ...fixupConfigRules(compat.extends(
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:testing-library/dom",
)), {
plugins: {
"@typescript-eslint": typescriptEslint,
"@stylistic": stylistic,
react: fixupPluginRules(react),
"react-hooks": fixupPluginRules(reactHooks),
"testing-library": fixupPluginRules(testingLibrary),
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
},

ecmaVersion: 2020,
sourceType: "module",
},

settings: {
react: {
version: "detect",
},
},

rules: {
"comma-dangle": ["error", "always-multiline"],
"consistent-return": "error",

indent: ["error", 4, {
SwitchCase: 1,
}],

quotes: "error",
semi: "error",
"keyword-spacing": "error",
"space-before-blocks": "error",

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

"no-multi-spaces": "error",
},
}, ...compat.extends(
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
).map(config => ({
...config,
files: ["**/*.ts", "**/*.tsx"],
})), {
files: ["**/*.ts", "**/*.tsx"],

languageOptions: {
parserOptions: {
project: ["./tsconfig.json", "./test/tsconfig.json", "./example/tsconfig.json"],
},
},

rules: {
indent: "off",
"no-return-await": "off",

"@stylistic/indent": ["error", 4, {
SwitchCase: 1,
}],
"@stylistic/member-delimiter-style": "error",
"@stylistic/object-curly-spacing": ["error", "always"],

"@typescript-eslint/return-await": ["error", "always"],
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
},
}, {
files: ["src/**/*"],

languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.node).map(([key]) => [key, "off"])),
},
},
}, {
files: ["src/**/*.test.*", "test/**/*"],

languageOptions: {
globals: {
...globals.jest,
},
},

rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/unbound-method": "off",
},
}];
Loading

0 comments on commit 537b1c3

Please sign in to comment.