Skip to content

Commit

Permalink
chore: remove eslint-plugin-svelte3 from demo site
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Sep 22, 2023
1 parent b38f1b7 commit 4f66e48
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 86 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion explorer-v2/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
1 change: 0 additions & 1 deletion explorer-v2/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

This file was deleted.

50 changes: 0 additions & 50 deletions explorer-v2/build-system/pre-build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 0 additions & 1 deletion explorer-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 2 additions & 25 deletions explorer-v2/src/lib/ESLintPlayground.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -51,25 +49,14 @@
});
}
}
$: {
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 = (() => {
const serializeCode = DEFAULT_CODE === code ? undefined : code;
const serializeRules = equalsRules(DEFAULT_RULES_CONFIG, rules) ? undefined : rules;
return serializeState({
code: serializeCode,
rules: serializeRules,
useEslintPluginSvelte3: useEslintPluginSvelte3 ? true : undefined
rules: serializeRules
});
})();
$: {
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -121,14 +107,6 @@

<div class="playground-root">
<div class="playground-tools">
<label>
<input bind:checked={useEslintPluginSvelte3} type="checkbox" />
See result of
<a href="https://github.com/sveltejs/eslint-plugin-svelte3">eslint-plugin-svelte3</a>.
</label>
{#if useEslintPluginSvelte3}
<span style="color: red">svelte-eslint-parser is not used.</span>
{/if}
<span style="margin-left: 16px">{time}</span>
</div>
<div class="playground-content">
Expand All @@ -138,7 +116,7 @@
{linter}
bind:code
config={{
parser: useEslintPluginSvelte3 ? undefined : 'svelte-eslint-parser',
parser: 'svelte-eslint-parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
Expand All @@ -150,7 +128,6 @@
es2021: true
}
}}
{options}
class="eslint-playground"
on:result={onLintedResult}
/>
Expand Down
3 changes: 0 additions & 3 deletions explorer-v2/src/lib/scripts/state/deserialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
3 changes: 1 addition & 2 deletions explorer-v2/src/lib/scripts/state/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion explorer-v2/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
Expand Down

0 comments on commit 4f66e48

Please sign in to comment.