diff --git a/.eslintrc.json b/.eslintrc.json index cf237947..3a3cd1c7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -14,5 +14,6 @@ "rules": { "no-unused-vars": ["warn", { "destructuredArrayIgnorePattern": ".", "ignoreRestSiblings": false }], "import/no-extraneous-dependencies": ["error", {"devDependencies": true}] - } + }, + "files": ["**/*.mjs", "**/*.js"] } diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..19d9bb39 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,86 @@ +import _import from 'eslint-plugin-import'; +import { fixupPluginRules } from '@eslint/compat'; +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: [ + '**/krill-parser.js', + '**/krill.pegjs', + '**/.eslintrc.json', + '**/server.js', + '**/tidal-sniffer.js', + '**/*.jsx', + '**/tunejs.js', + 'out/**/*', + '**/postcss.config.js', + '**/postcss.config.cjs', + '**/tailwind.config.js', + '**/tailwind.config.cjs', + '**/vite.config.js', + '**/dist/**/*', + '!**/*.mjs', + '**/*.tsx', + '**/*.ts', + '**/*.json', + '**/dev-dist', + '**/dist', + 'src-tauri/target/**/*', + '**/reverbGen.mjs', + '**/hydra.mjs', + '**/jsdoc-synonyms.js', + 'packages/hs2js/src/hs2js.mjs', + '**/samples', + ], + }, + ...compat.extends('eslint:recommended').map((config) => ({ + ...config, + files: ['**/*.mjs', '**/*.js'], + })), + { + files: ['**/*.mjs', '**/*.js'], + + plugins: { + import: fixupPluginRules(_import), + }, + + languageOptions: { + globals: { + ...globals.node, + ...globals.browser, + }, + + ecmaVersion: 'latest', + sourceType: 'module', + }, + + rules: { + 'no-unused-vars': [ + 'warn', + { + destructuredArrayIgnorePattern: '.', + ignoreRestSiblings: false, + }, + ], + + 'import/no-extraneous-dependencies': [ + 'error', + { + devDependencies: true, + }, + ], + }, + }, +]; diff --git a/package.json b/package.json index 3c7355c3..0a7a49ba 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "osc": "cd packages/osc && npm run server", "jsdoc": "jsdoc packages/ -c jsdoc/jsdoc.config.json", "jsdoc-json": "jsdoc packages/ --template ./node_modules/jsdoc-json --destination doc.json -c jsdoc/jsdoc.config.json", - "lint": "eslint . --ext mjs,js --quiet", + "lint": "eslint . --quiet", "codeformat": "prettier --write .", "format-check": "prettier --check .", "report-undocumented": "npm run jsdoc-json && node jsdoc/undocumented.mjs > undocumented.json", @@ -55,6 +55,9 @@ "@strudel/xen": "workspace:*" }, "devDependencies": { + "@eslint/compat": "^1.2.5", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "^9.19.0", "@tauri-apps/cli": "^2.2.5", "@vitest/ui": "^3.0.4", "acorn": "^8.14.0", @@ -62,6 +65,7 @@ "eslint": "^9.18.0", "eslint-plugin-import": "^2.31.0", "events": "^3.3.0", + "globals": "^15.14.0", "jsdoc": "^4.0.4", "jsdoc-json": "^2.0.2", "lerna": "^8.1.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2e48efc..29624333 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,6 +27,15 @@ importers: specifier: workspace:* version: link:packages/xen devDependencies: + '@eslint/compat': + specifier: ^1.2.5 + version: 1.2.5(eslint@9.19.0(jiti@2.4.2)) + '@eslint/eslintrc': + specifier: ^3.2.0 + version: 3.2.0 + '@eslint/js': + specifier: ^9.19.0 + version: 9.19.0 '@tauri-apps/cli': specifier: ^2.2.5 version: 2.2.7 @@ -48,6 +57,9 @@ importers: events: specifier: ^3.3.0 version: 3.3.0 + globals: + specifier: ^15.14.0 + version: 15.14.0 jsdoc: specifier: ^4.0.4 version: 4.0.4 @@ -1646,6 +1658,15 @@ packages: resolution: {integrity: sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + '@eslint/compat@1.2.5': + resolution: {integrity: sha512-5iuG/StT+7OfvhoBHPlmxkPA9om6aDUFgmD4+mWKAGsYt4vCe8rypneG03AuseyRHBmcCLXQtIH5S26tIoggLg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^9.10.0 + peerDependenciesMeta: + eslint: + optional: true + '@eslint/config-array@0.19.1': resolution: {integrity: sha512-fo6Mtm5mWyKjA/Chy1BYTdn5mGJoDNjC7C64ug20ADsRDGrA85bN3uK3MaKbeRkRuuIEAR5N33Jr1pbm411/PA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -4450,6 +4471,10 @@ packages: resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==} engines: {node: '>=18'} + globals@15.14.0: + resolution: {integrity: sha512-OkToC372DtlQeje9/zHIo5CT8lRP/FUgEOKBEhU4e0abL7J7CD24fD9ohiLN5hagG/kWCYj4K5oaxxtj2Z0Dig==} + engines: {node: '>=18'} + globalthis@1.0.4: resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} @@ -8938,6 +8963,10 @@ snapshots: '@eslint-community/regexpp@4.12.1': {} + '@eslint/compat@1.2.5(eslint@9.19.0(jiti@2.4.2))': + optionalDependencies: + eslint: 9.19.0(jiti@2.4.2) + '@eslint/config-array@0.19.1': dependencies: '@eslint/object-schema': 2.1.5 @@ -12406,6 +12435,8 @@ snapshots: globals@14.0.0: {} + globals@15.14.0: {} + globalthis@1.0.4: dependencies: define-properties: 1.2.1