From 4f66e487435e2baa320bd912a81c50e47d122bee Mon Sep 17 00:00:00 2001 From: ota-meshi Date: Sat, 23 Sep 2023 00:00:27 +0900 Subject: [PATCH] chore: remove eslint-plugin-svelte3 from demo site --- .eslintignore | 1 - explorer-v2/.gitignore | 1 - explorer-v2/.prettierignore | 1 - .../pre-build/eslint-plugin-svelte3.js | 1 - .../build-system/pre-build/webpack.config.js | 50 ------------------- explorer-v2/package.json | 1 - explorer-v2/src/lib/ESLintPlayground.svelte | 27 +--------- .../src/lib/scripts/state/deserialize.js | 3 -- .../src/lib/scripts/state/serialize.js | 3 +- explorer-v2/vite.config.js | 1 - 10 files changed, 3 insertions(+), 86 deletions(-) delete mode 100644 explorer-v2/build-system/pre-build/eslint-plugin-svelte3.js diff --git a/.eslintignore b/.eslintignore index 0c3d71d6..87b3b148 100644 --- a/.eslintignore +++ b/.eslintignore @@ -10,7 +10,6 @@ /explorer-v2/build /explorer-v2/build-system/shim/svelte-eslint-parser.* /explorer-v2/build-system/shim/eslint-scope.* -/explorer-v2/build-system/shim/eslint-plugin-svelte3.* /explorer-v2/build-system/shim/eslint.* /explorer-v2/build-system/shim/svelte/* !/.vscode diff --git a/explorer-v2/.gitignore b/explorer-v2/.gitignore index 3ffdbcb5..72917e99 100644 --- a/explorer-v2/.gitignore +++ b/explorer-v2/.gitignore @@ -5,6 +5,5 @@ node_modules /functions /build-system/shim/svelte-eslint-parser.* /build-system/shim/eslint-scope.* -/build-system/shim/eslint-plugin-svelte3.* /build-system/shim/eslint.* /build-system/shim/svelte/* diff --git a/explorer-v2/.prettierignore b/explorer-v2/.prettierignore index 44a3bdf3..19f6507d 100644 --- a/explorer-v2/.prettierignore +++ b/explorer-v2/.prettierignore @@ -4,5 +4,4 @@ build/** node_modules/** /build-system/shim/svelte-eslint-parser.* /build-system/shim/eslint-scope.* -/build-system/shim/eslint-plugin-svelte3.* /build-system/shim/eslint.* diff --git a/explorer-v2/build-system/pre-build/eslint-plugin-svelte3.js b/explorer-v2/build-system/pre-build/eslint-plugin-svelte3.js deleted file mode 100644 index b1dfc60f..00000000 --- a/explorer-v2/build-system/pre-build/eslint-plugin-svelte3.js +++ /dev/null @@ -1 +0,0 @@ -export { processors } from 'eslint-plugin-svelte3'; diff --git a/explorer-v2/build-system/pre-build/webpack.config.js b/explorer-v2/build-system/pre-build/webpack.config.js index a0fb58a9..ce17ed70 100644 --- a/explorer-v2/build-system/pre-build/webpack.config.js +++ b/explorer-v2/build-system/pre-build/webpack.config.js @@ -85,56 +85,6 @@ export default [ }) ] }, - { - ...base, - entry: { - 'eslint-plugin-svelte3': resolve('./eslint-plugin-svelte3.js') - }, - module: { - rules: [ - { - test: /node_modules\/eslint-plugin-svelte3\/index\.js$/u, - loader: 'string-replace-loader', - options: { - search: 'Object\\.keys\\(__require\\.cache\\)', - replace: (original) => `[] /* ${original} */`, - flags: '' - } - }, - { - test: /node_modules\/eslint-plugin-svelte3\/index\.js$/u, - loader: 'string-replace-loader', - options: { - search: 'require\\(linter_path\\)', - replace: (original) => `require('eslint'); // ${original}`, - flags: '' - } - }, - { - test: /node_modules\/eslint-plugin-svelte3\/index\.js$/u, - loader: 'string-replace-loader', - options: { - search: "throw new Error\\('Could not find ESLint Linter in require cache'\\);", - replace: (original) => ` // ${original}`, - flags: '' - } - } - ] - }, - externals: { - 'svelte/compiler': '$$inject_svelte_compiler$$', - eslint: '$$inject_eslint$$' - }, - plugins: [ - new WrapperPlugin({ - test: /eslint-plugin-svelte3\.js/, - header: ` - import * as $$inject_svelte_compiler$$ from 'svelte/compiler'; - import * as $$inject_eslint$$ from 'eslint'; - ` - }) - ] - }, { ...base, entry: { diff --git a/explorer-v2/package.json b/explorer-v2/package.json index 9ba7d1ff..645e6437 100644 --- a/explorer-v2/package.json +++ b/explorer-v2/package.json @@ -15,7 +15,6 @@ "@fontsource/fira-mono": "^5.0.0", "@typescript-eslint/parser": "^6.0.0", "eslint": "^8.0.0", - "eslint-plugin-svelte3": "^4.0.0", "eslint-scope": "^7.0.0", "esquery": "^1.5.0", "pako": "^2.0.3", diff --git a/explorer-v2/src/lib/ESLintPlayground.svelte b/explorer-v2/src/lib/ESLintPlayground.svelte index b273bad8..fd441e00 100644 --- a/explorer-v2/src/lib/ESLintPlayground.svelte +++ b/explorer-v2/src/lib/ESLintPlayground.svelte @@ -30,9 +30,7 @@ let code = state.code || DEFAULT_CODE; let rules = state.rules || Object.assign({}, DEFAULT_RULES_CONFIG); let messages = []; - let useEslintPluginSvelte3 = Boolean(state.useEslintPluginSvelte3); let time = ''; - let options = {}; $: hasLangTs = /lang\s*=\s*(?:"ts"|ts|'ts'|"typescript"|typescript|'typescript')/u.test(code); let tsParser = undefined; @@ -51,16 +49,6 @@ }); } } - $: { - options = useEslintPluginSvelte3 ? getEslintPluginSvelte3Options() : {}; - } - async function getEslintPluginSvelte3Options() { - const pluginSvelte3 = await import('eslint-plugin-svelte3'); - return { - preprocess: pluginSvelte3.processors.svelte3.preprocess, - postprocess: pluginSvelte3.processors.svelte3.postprocess - }; - } // eslint-disable-next-line no-use-before-define -- false positive $: serializedString = (() => { @@ -68,8 +56,7 @@ const serializeRules = equalsRules(DEFAULT_RULES_CONFIG, rules) ? undefined : rules; return serializeState({ code: serializeCode, - rules: serializeRules, - useEslintPluginSvelte3: useEslintPluginSvelte3 ? true : undefined + rules: serializeRules }); })(); $: { @@ -98,7 +85,6 @@ const state = deserializeState(newSerializedString); code = state.code || DEFAULT_CODE; rules = state.rules || Object.assign({}, DEFAULT_RULES_CONFIG); - useEslintPluginSvelte3 = Boolean(state.useEslintPluginSvelte3); } } @@ -121,14 +107,6 @@
- - {#if useEslintPluginSvelte3} - svelte-eslint-parser is not used. - {/if} {time}
@@ -138,7 +116,7 @@ {linter} bind:code config={{ - parser: useEslintPluginSvelte3 ? undefined : 'svelte-eslint-parser', + parser: 'svelte-eslint-parser', parserOptions: { ecmaVersion: 2020, sourceType: 'module', @@ -150,7 +128,6 @@ es2021: true } }} - {options} class="eslint-playground" on:result={onLintedResult} /> diff --git a/explorer-v2/src/lib/scripts/state/deserialize.js b/explorer-v2/src/lib/scripts/state/deserialize.js index c68a14e1..eae07f08 100644 --- a/explorer-v2/src/lib/scripts/state/deserialize.js +++ b/explorer-v2/src/lib/scripts/state/deserialize.js @@ -26,9 +26,6 @@ export function deserializeState(serializedString) { if (typeof json.code === 'string') { state.code = json.code; } - if (json.useEslintPluginSvelte3 === true) { - state.useEslintPluginSvelte3 = true; - } if (typeof json.rules === 'object' && json.rules != null) { state.rules = {}; diff --git a/explorer-v2/src/lib/scripts/state/serialize.js b/explorer-v2/src/lib/scripts/state/serialize.js index bb8e80d3..58cbedf5 100644 --- a/explorer-v2/src/lib/scripts/state/serialize.js +++ b/explorer-v2/src/lib/scripts/state/serialize.js @@ -22,8 +22,7 @@ function getEnabledRules(allRules) { export function serializeState(state) { const saveData = { code: state.code, - rules: state.rules ? getEnabledRules(state.rules) : undefined, - useEslintPluginSvelte3: state.useEslintPluginSvelte3 + rules: state.rules ? getEnabledRules(state.rules) : undefined }; const jsonString = JSON.stringify(saveData); // eslint-disable-next-line n/no-unsupported-features/node-builtins -- ignore diff --git a/explorer-v2/vite.config.js b/explorer-v2/vite.config.js index e6101474..0c0fdd0c 100644 --- a/explorer-v2/vite.config.js +++ b/explorer-v2/vite.config.js @@ -18,7 +18,6 @@ const config = { tslib: resolve('./node_modules/tslib/tslib.es6.js'), eslint: resolve('./build-system/shim/eslint.js'), 'svelte-eslint-parser': resolve('./build-system/shim/svelte-eslint-parser.js'), - 'eslint-plugin-svelte3': resolve('./build-system/shim/eslint-plugin-svelte3.js'), 'svelte/compiler': resolve('./build-system/shim/svelte/compiler.js') } }