Skip to content

Commit

Permalink
improve eslint setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkev committed Sep 30, 2024
1 parent cec6674 commit a2eb095
Show file tree
Hide file tree
Showing 3 changed files with 447 additions and 1,301 deletions.
57 changes: 38 additions & 19 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import { fixupConfigRules } from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import tsParser from "@typescript-eslint/parser";
import eslint from "@eslint/js";
import reactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import tseslint from "typescript-eslint";

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,
recommendedConfig: eslint.configs.recommended,
allConfig: eslint.configs.all,
});

export default [
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
ignores: ["**/dist", "**/.eslintrc.cjs"],
ignores: ["**/dist", "eslint.config.mjs", "docs"],
},
...fixupConfigRules(
compat.extends(
Expand All @@ -35,19 +37,9 @@ export default [
globals: {
...globals.browser,
},
parser: tsParser,

ecmaVersion: "latest",
sourceType: "module",
parserOptions: {
project: [
"./tsconfig.node.json",
"./packages/site/tsconfig.json",
"./packages/site/tsconfig.node.json",
"./packages/webgpu-waveform/tsconfig.json",
"./packages/webgpu-waveform/tsconfig.node.json",
],
tsconfigRootDir: __dirname,
},
},

settings: {
Expand All @@ -57,13 +49,40 @@ export default [
},

rules: {
"@typescript-eslint/no-empty-function": [
"warn",
{
allow: ["private-constructors"],
},
],

"@typescript-eslint/ban-types": "off",
"no-useless-escape": "off",
indent: "off",
quotes: "off",
"no-unused-vars": "off",

"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],

"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"react/no-unescaped-entities": "off",
"no-case-declarations": "off",
"react-refresh/only-export-components": [
"warn",
{
allowConstantExport: true,
},
],
},
},
];
}
);
25 changes: 12 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.17.0",
"eslint": "^8.57.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-react": "^7.35.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.9",
"nx": "19.4.3",
"@nx/eslint": "19.4.3"
},
"dependencies": {
"@eslint/compat": "^1.1.1",
"globals": "^15.8.0"
"@eslint/js": "^9.11.1",
"@nx/eslint": "19.8.2",
"@types/eslint__js": "^8.42.3",
"eslint": "^9.11.1",
"eslint-plugin-react": "^7.37.0",
"eslint-plugin-react-hooks": "^5.1.0-rc-e948a5ac-20240807",
"eslint-plugin-react-refresh": "^0.4.12",
"globals": "^15.9.0",
"nx": "19.8.2",
"typescript": "^5.5.2",
"typescript-eslint": "^8.7.0"
},
"packageManager": "pnpm@9.9.0+sha512.60c18acd138bff695d339be6ad13f7e936eea6745660d4cc4a776d5247c540d0edee1a563695c183a66eb917ef88f2b4feb1fc25f32a7adcadc7aaf3438e99c1"
"packageManager": "pnpm@9.11.0"
}
Loading

0 comments on commit a2eb095

Please sign in to comment.