Skip to content

Commit 6aa0c2d

Browse files
committed
Update demo site
1 parent 3b3f389 commit 6aa0c2d

File tree

10 files changed

+69
-28
lines changed

10 files changed

+69
-28
lines changed

explorer-v2/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules
66
/build-system/shim/svelte-eslint-parser.*
77
/build-system/shim/eslint-scope.*
88
/build-system/shim/eslint-plugin-svelte3.*
9+
/build-system/shim/eslint.*

explorer-v2/.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
static/**
33
build/**
44
node_modules/**
5+
/build-system/shim/svelte-eslint-parser.*
6+
/build-system/shim/eslint-scope.*
7+
/build-system/shim/eslint-plugin-svelte3.*
8+
/build-system/shim/eslint.*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Linter } from '../../node_modules/eslint/lib/linter/linter.js';

explorer-v2/build-system/pre-build/webpack.config.js

+34-4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,36 @@ const base = {
3535
};
3636
/** @type {import('webpack').Configuration[]} */
3737
export default [
38+
{
39+
...base,
40+
entry: {
41+
eslint: resolve('./eslint.js')
42+
},
43+
externals: {
44+
espree: '$$inject_espree$$',
45+
esquery: '$$inject_esquery$$'
46+
},
47+
plugins: [
48+
new WrapperPlugin({
49+
test: /eslint\.js/,
50+
header: `
51+
if (typeof window !== "undefined") {
52+
if (typeof window.global === "undefined") {
53+
window.global = {}
54+
}
55+
if (typeof window.process === "undefined") {
56+
window.process = {
57+
env: {},
58+
cwd: () => undefined,
59+
}
60+
}
61+
}
62+
import * as $$inject_espree$$ from 'espree';
63+
import $$inject_esquery$$ from 'esquery';
64+
`
65+
})
66+
]
67+
},
3868
{
3969
...base,
4070
entry: {
@@ -49,7 +79,7 @@ export default [
4979
test: /svelte-eslint-parser\.js/,
5080
header: `
5181
import * as $$inject_svelte_compiler$$ from 'svelte/compiler';
52-
import $$inject_espree$$ from 'espree';
82+
import * as $$inject_espree$$ from 'espree';
5383
`
5484
})
5585
]
@@ -75,7 +105,7 @@ export default [
75105
loader: 'string-replace-loader',
76106
options: {
77107
search: 'require\\(linter_path\\)',
78-
replace: (original) => `{Linter:require('eslint4b')}; // ${original}`,
108+
replace: (original) => `require('eslint'); // ${original}`,
79109
flags: ''
80110
}
81111
},
@@ -92,14 +122,14 @@ export default [
92122
},
93123
externals: {
94124
'svelte/compiler': '$$inject_svelte_compiler$$',
95-
eslint4b: '$$inject_eslint4b$$'
125+
eslint: '$$inject_eslint$$'
96126
},
97127
plugins: [
98128
new WrapperPlugin({
99129
test: /eslint-plugin-svelte3\.js/,
100130
header: `
101131
import * as $$inject_svelte_compiler$$ from 'svelte/compiler';
102-
import $$inject_eslint4b$$ from 'eslint4b';
132+
import * as $$inject_eslint$$ from 'eslint';
103133
`
104134
})
105135
]

explorer-v2/build-system/shim/path.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export default {
2-
extname(p) {
3-
return /\.[^.]*$/.exec(p)?.[0];
4-
}
2+
extname
53
};
4+
5+
export function extname(p) {
6+
return /\.[^.]*$/.exec(p)?.[0];
7+
}

explorer-v2/build-system/shim/util.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
export default {};
1+
export default new Proxy(
2+
{},
3+
{
4+
get(target, key) {
5+
console.log(key);
6+
if (key === 'inspect') {
7+
return {};
8+
}
9+
return target[key];
10+
}
11+
}
12+
);

explorer-v2/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"devDependencies": {
1414
"@sveltejs/adapter-static": "^1.0.0-next.13",
1515
"@sveltejs/kit": "^1.0.0-next.138",
16-
"eslint": "^8.0.0",
1716
"prettier": "^2.3.0",
1817
"prettier-plugin-svelte": "^2.3.0",
1918
"string-replace-loader": "^3.0.1",
@@ -26,9 +25,9 @@
2625
"@fontsource/fira-mono": "^4.2.2",
2726
"@lukeed/uuid": "^2.0.0",
2827
"cookie": "^0.4.1",
28+
"eslint": "^8.0.0",
2929
"eslint-plugin-svelte3": "^3.2.0",
3030
"eslint-scope": "^6.0.0",
31-
"eslint4b": "^7.26.0",
3231
"pako": "^2.0.3",
3332
"svelte": "^3.41.0",
3433
"svelte-eslint-parser": "file:.."

explorer-v2/src/lib/ESLintPlayground.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script>
22
import { onDestroy, onMount } from 'svelte';
3-
import Linter from 'eslint4b';
3+
import { Linter } from 'eslint';
44
import * as svelteEslintParser from 'svelte-eslint-parser';
55
import ESLintEditor from './ESLintEditor.svelte';
66
import RulesSettings from './RulesSettings.svelte';

explorer-v2/src/lib/scripts/rules.js

+8-17
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
import Linter from 'eslint4b';
1+
import { Linter } from 'eslint';
22

33
const linter = new Linter();
44

55
export const categories = [
66
{
7+
type: 'problem',
78
title: 'Possible Errors',
89
rules: []
910
},
1011
{
11-
title: 'Best Practices',
12+
type: 'suggestion',
13+
title: 'Suggestions',
1214
rules: []
1315
},
1416
{
15-
title: 'Strict Mode',
16-
rules: []
17-
},
18-
{
19-
title: 'Variables',
20-
rules: []
21-
},
22-
{
23-
title: 'Stylistic Issues',
24-
rules: []
25-
},
26-
{
27-
title: 'ECMAScript 6',
17+
type: 'layout',
18+
title: 'Layout & Formatting',
2819
rules: []
2920
}
3021
];
@@ -41,8 +32,8 @@ for (const [ruleId, rule] of linter.getRules()) {
4132
url: rule.meta.docs.url
4233
};
4334
rules.push(data);
44-
const category = rule.meta.docs.category;
45-
categories.find((c) => c.title === category).rules.push(data);
35+
const type = rule.meta.type;
36+
categories.find((c) => c.type === type).rules.push(data);
4637

4738
if (rule.meta.docs.recommended) {
4839
DEFAULT_RULES_CONFIG[ruleId] = 'error';

explorer-v2/svelte.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const config = {
2121
assert: resolve('./build-system/shim/assert.js'),
2222
path: resolve('./build-system/shim/path.js'),
2323
fs: resolve('./build-system/shim/fs.js'),
24+
module: resolve('./build-system/shim/module.js'),
25+
eslint: resolve('./build-system/shim/eslint.js'),
2426
'svelte-eslint-parser': resolve('./build-system/shim/svelte-eslint-parser.js'),
2527
'eslint-plugin-svelte3': resolve('./build-system/shim/eslint-plugin-svelte3.js')
2628
}

0 commit comments

Comments
 (0)