From c6dedb482afa8698c033f5e74ab1240b83e75a72 Mon Sep 17 00:00:00 2001 From: Denis Mishankov Date: Tue, 1 Oct 2024 08:52:05 +0300 Subject: [PATCH] migrate to new eslint config file --- .eslintrc.cjs | 31 --------------------- eslint.config.mjs | 68 +++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 21 ++++++++++++--- package.json | 3 +++ 4 files changed, 89 insertions(+), 34 deletions(-) delete mode 100644 .eslintrc.cjs create mode 100644 eslint.config.mjs diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 0b75758..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,31 +0,0 @@ -/** @type { import("eslint").Linter.Config } */ -module.exports = { - root: true, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:svelte/recommended', - 'prettier' - ], - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - parserOptions: { - sourceType: 'module', - ecmaVersion: 2020, - extraFileExtensions: ['.svelte'] - }, - env: { - browser: true, - es2017: true, - node: true - }, - overrides: [ - { - files: ['*.svelte'], - parser: 'svelte-eslint-parser', - parserOptions: { - parser: '@typescript-eslint/parser' - } - } - ] -}; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..d49bbb3 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,68 @@ +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import globals from "globals"; +import tsParser from "@typescript-eslint/parser"; +import parser from "svelte-eslint-parser"; +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: [ + "**/.DS_Store", + "**/node_modules", + "build", + ".svelte-kit", + "package", + "**/.env", + "**/.env.*", + "!**/.env.example", + "**/pnpm-lock.yaml", + "**/package-lock.json", + "**/yarn.lock", + ], +}, ...compat.extends( + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:svelte/recommended", + "prettier", +), { + plugins: { + "@typescript-eslint": typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + + parser: tsParser, + ecmaVersion: 2020, + sourceType: "module", + + parserOptions: { + extraFileExtensions: [".svelte"], + }, + }, +}, { + files: ["**/*.svelte"], + + languageOptions: { + parser: parser, + ecmaVersion: 5, + sourceType: "script", + + parserOptions: { + parser: "@typescript-eslint/parser", + }, + }, +}]; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d11eb16..04b64ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,8 @@ "name": "string-manipulator", "version": "0.0.1", "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.11.1", "@sveltejs/adapter-auto": "^3.2.5", "@sveltejs/adapter-static": "^3.0.5", "@sveltejs/kit": "^2.6.1", @@ -18,6 +20,7 @@ "eslint": "^9.11.1", "eslint-config-prettier": "^9.1.0", "eslint-plugin-svelte": "^2.44.1", + "globals": "^15.9.0", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.7", "svelte": "^4.2.19", @@ -549,6 +552,18 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/eslintrc/node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", @@ -2157,9 +2172,9 @@ } }, "node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "version": "15.9.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.9.0.tgz", + "integrity": "sha512-SmSKyLLKFbSr6rptvP8izbyxJL4ILwqO9Jg23UA0sDlGlu58V59D1//I3vlc0KJphVdUR7vMjHIplYnzBxorQA==", "dev": true, "engines": { "node": ">=18" diff --git a/package.json b/package.json index 1072655..043a507 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,8 @@ "format": "prettier --write ." }, "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.11.1", "@sveltejs/adapter-auto": "^3.2.5", "@sveltejs/adapter-static": "^3.0.5", "@sveltejs/kit": "^2.6.1", @@ -24,6 +26,7 @@ "eslint": "^9.11.1", "eslint-config-prettier": "^9.1.0", "eslint-plugin-svelte": "^2.44.1", + "globals": "^15.9.0", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.7", "svelte": "^4.2.19",