Skip to content

Commit 2d88680

Browse files
Merge branch 'master' into feat/force-types-on-object-props
2 parents bfa7a9f + a4226ea commit 2d88680

File tree

408 files changed

+7298
-3082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

408 files changed

+7298
-3082
lines changed

.eslintignore

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
/tests/fixtures
55
/tests/integrations/eslint-plugin-import
66

7-
!.vuepress
8-
/docs/.vuepress/dist
7+
!.vitepress
8+
/docs/.vitepress/dist
9+
/docs/.vitepress/build-system/shim/eslint.mjs
10+
/docs/.vitepress/build-system/shim/assert.mjs
11+
/docs/.vitepress/.temp
12+
/docs/.vitepress/cache

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@
77
/test.*
88
yarn.lock
99
yarn-error.log
10-
docs/.vuepress/dist
10+
/docs/.vitepress/dist
11+
/docs/.vitepress/build-system/shim/eslint.mjs
12+
/docs/.vitepress/build-system/shim/assert.mjs
13+
/docs/.vitepress/.temp
14+
/docs/.vitepress/cache
1115
typings/eslint/lib/rules

docs/.vitepress/build-system/build.ts

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Pre-build cjs packages that cannot be bundled well.
3+
*/
4+
import esbuild from 'esbuild'
5+
import path from 'path'
6+
import fs from 'fs'
7+
import { fileURLToPath } from 'url'
8+
9+
const dirname = path.dirname(
10+
fileURLToPath(
11+
// @ts-expect-error -- Cannot change `module` option
12+
import.meta.url
13+
)
14+
)
15+
16+
build(
17+
path.join(dirname, './src/eslint.mjs'),
18+
path.join(dirname, './shim/eslint.mjs'),
19+
['path', 'assert', 'util', 'esquery']
20+
)
21+
build(
22+
path.join(dirname, '../../../node_modules/assert'),
23+
path.join(dirname, './shim/assert.mjs'),
24+
['path']
25+
)
26+
27+
function build(input: string, out: string, injects: string[] = []) {
28+
// eslint-disable-next-line no-console -- ignore
29+
console.log(`build@ ${input}`)
30+
let code = bundle(input, injects)
31+
code = transform(code, injects)
32+
fs.mkdirSync(path.dirname(out), { recursive: true })
33+
fs.writeFileSync(out, code, 'utf8')
34+
}
35+
36+
function bundle(entryPoint: string, externals: string[]) {
37+
const result = esbuild.buildSync({
38+
entryPoints: [entryPoint],
39+
format: 'esm',
40+
bundle: true,
41+
external: externals,
42+
write: false,
43+
inject: [path.join(dirname, './src/process-shim.mjs')]
44+
})
45+
46+
return `${result.outputFiles[0].text}`
47+
}
48+
49+
function transform(code: string, injects: string[]) {
50+
const newCode = code.replace(/"[a-z]+" = "[a-z]+";/u, '')
51+
return `
52+
${injects
53+
.map(
54+
(inject) =>
55+
`import $inject_${inject.replace(/-/gu, '_')}$ from '${inject}';`
56+
)
57+
.join('\n')}
58+
const $_injects_$ = {${injects
59+
.map((inject) => `${inject.replace(/-/gu, '_')}:$inject_${inject}$`)
60+
.join(',\n')}};
61+
function require(module, ...args) {
62+
return $_injects_$[module] || {}
63+
}
64+
${newCode}
65+
`
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import esquery from '../../../../node_modules/esquery/dist/esquery.esm.js'
2+
3+
export const { parse, match, traverse, matches, query } = esquery
4+
5+
export { default } from '../../../../node_modules/esquery/dist/esquery.esm.js'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {}
2+
export default {}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// @ts-nocheck
2+
export const sep = '/'
3+
export function basename(path, ext) {
4+
const b = (/[^\/]*$/u.exec(path) || [''])[0]
5+
return ext && b.endsWith(ext) ? b.slice(0, -ext.length) : b
6+
}
7+
export function extname(path) {
8+
return (/[^.\/]*$/u.exec(path) || [''])[0]
9+
}
10+
export function isAbsolute() {
11+
return false
12+
}
13+
export function join(...args) {
14+
return args.length > 0 ? normalize(args.join('/')) : '.'
15+
}
16+
17+
function normalize(path) {
18+
const result = []
19+
for (const part of path.replace(/\/+/gu, '/').split('/')) {
20+
if (part === '..') {
21+
if (result[0] && result[0] !== '..' && result[0] !== '.') result.shift()
22+
} else if (part === '.' && result.length > 0) {
23+
// noop
24+
} else {
25+
result.unshift(part)
26+
}
27+
}
28+
return result.reverse().join('/')
29+
}
30+
const posix = {
31+
sep,
32+
basename,
33+
extname,
34+
isAbsolute,
35+
join
36+
}
37+
posix.posix = posix
38+
export default posix
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @ts-nocheck
2+
import * as all from '../../../../node_modules/eslint/lib/linter/linter.js'
3+
const Linter = all.Linter
4+
export { Linter }
5+
export default { Linter }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* globals window */
2+
// @ts-nocheck
3+
export const process = {
4+
env: {},
5+
cwd: () => '',
6+
stdout: {}
7+
}
8+
if (typeof window !== 'undefined') {
9+
window.process = process
10+
}

docs/.vitepress/config.ts

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
import type { DefaultTheme } from 'vitepress'
2+
import { defineConfig } from 'vitepress'
3+
import { BUNDLED_LANGUAGES } from 'shiki'
4+
import path from 'path'
5+
import { fileURLToPath } from 'url'
6+
import rules from '../../tools/lib/rules'
7+
import { viteCommonjs, vitePluginRequireResolve } from './vite-plugin'
8+
9+
// Pre-build cjs packages that cannot be bundled well.
10+
import './build-system/build'
11+
12+
const dirname = path.dirname(
13+
fileURLToPath(
14+
// @ts-expect-error -- Cannot change `module` option
15+
import.meta.url
16+
)
17+
)
18+
19+
// Include `json5` as alias for jsonc
20+
const jsonc = BUNDLED_LANGUAGES.find((lang) => lang.id === 'jsonc')
21+
if (jsonc) {
22+
jsonc.aliases = [...(jsonc.aliases ?? []), 'json5']
23+
}
24+
25+
const uncategorizedRules = rules.filter(
26+
(rule) =>
27+
!rule.meta.docs.categories &&
28+
!rule.meta.docs.extensionRule &&
29+
!rule.meta.deprecated
30+
)
31+
const uncategorizedExtensionRule = rules.filter(
32+
(rule) =>
33+
!rule.meta.docs.categories &&
34+
rule.meta.docs.extensionRule &&
35+
!rule.meta.deprecated
36+
)
37+
const deprecatedRules = rules.filter((rule) => rule.meta.deprecated)
38+
39+
const sidebarCategories = [
40+
{ title: 'Base Rules', categoryIds: ['base'] },
41+
{
42+
title: 'Priority A: Essential',
43+
categoryIds: ['vue3-essential', 'essential']
44+
},
45+
{
46+
title: 'Priority A: Essential for Vue.js 3.x',
47+
categoryIds: ['vue3-essential']
48+
},
49+
{ title: 'Priority A: Essential for Vue.js 2.x', categoryIds: ['essential'] },
50+
{
51+
title: 'Priority B: Strongly Recommended',
52+
categoryIds: ['vue3-strongly-recommended', 'strongly-recommended']
53+
},
54+
{
55+
title: 'Priority B: Strongly Recommended for Vue.js 3.x',
56+
categoryIds: ['vue3-strongly-recommended']
57+
},
58+
{
59+
title: 'Priority B: Strongly Recommended for Vue.js 2.x',
60+
categoryIds: ['strongly-recommended']
61+
},
62+
{
63+
title: 'Priority C: Recommended',
64+
categoryIds: ['vue3-recommended', 'recommended']
65+
},
66+
{
67+
title: 'Priority C: Recommended for Vue.js 3.x',
68+
categoryIds: ['vue3-recommended']
69+
},
70+
{
71+
title: 'Priority C: Recommended for Vue.js 2.x',
72+
categoryIds: ['recommended']
73+
}
74+
]
75+
76+
const categorizedRules: DefaultTheme.SidebarGroup[] = []
77+
for (const { title, categoryIds } of sidebarCategories) {
78+
const categoryRules = rules
79+
.filter((rule) => rule.meta.docs.categories && !rule.meta.deprecated)
80+
.filter((rule) =>
81+
categoryIds.every((categoryId) =>
82+
rule.meta.docs.categories.includes(categoryId)
83+
)
84+
)
85+
const children: DefaultTheme.SidebarItem[] = categoryRules
86+
.filter(({ ruleId }) => {
87+
const exists = categorizedRules.some(({ items }) =>
88+
items.some(({ text: alreadyRuleId }) => alreadyRuleId === ruleId)
89+
)
90+
return !exists
91+
})
92+
.map(({ ruleId, name }) => {
93+
return {
94+
text: ruleId,
95+
link: `/rules/${name}`
96+
}
97+
})
98+
99+
if (children.length === 0) {
100+
continue
101+
}
102+
categorizedRules.push({
103+
text: title,
104+
collapsible: false,
105+
items: children
106+
})
107+
}
108+
109+
const extraCategories: DefaultTheme.SidebarGroup[] = []
110+
if (uncategorizedRules.length > 0) {
111+
extraCategories.push({
112+
text: 'Uncategorized',
113+
collapsible: false,
114+
items: uncategorizedRules.map(({ ruleId, name }) => ({
115+
text: ruleId,
116+
link: `/rules/${name}`
117+
}))
118+
})
119+
}
120+
if (uncategorizedExtensionRule.length > 0) {
121+
extraCategories.push({
122+
text: 'Extension Rules',
123+
collapsible: false,
124+
items: uncategorizedExtensionRule.map(({ ruleId, name }) => ({
125+
text: ruleId,
126+
link: `/rules/${name}`
127+
}))
128+
})
129+
}
130+
if (deprecatedRules.length > 0) {
131+
extraCategories.push({
132+
text: 'Deprecated',
133+
collapsible: false,
134+
items: deprecatedRules.map(({ ruleId, name }) => ({
135+
text: ruleId,
136+
link: `/rules/${name}`
137+
}))
138+
})
139+
}
140+
141+
export default defineConfig({
142+
base: '/',
143+
title: 'eslint-plugin-vue',
144+
description: 'Official ESLint plugin for Vue.js',
145+
head: [['link', { rel: 'icon', href: '/favicon.png' }]],
146+
147+
vite: {
148+
publicDir: path.resolve(dirname, './public'),
149+
plugins: [vitePluginRequireResolve(), viteCommonjs()],
150+
resolve: {
151+
alias: {
152+
eslint: path.join(dirname, './build-system/shim/eslint.mjs'),
153+
assert: path.join(dirname, './build-system/shim/assert.mjs'),
154+
path: path.join(dirname, './build-system/shim/path.mjs'),
155+
156+
tslib: path.join(dirname, '../../node_modules/tslib/tslib.es6.js'),
157+
esquery: path.join(dirname, './build-system/shim/esquery.mjs'),
158+
globby: path.join(dirname, './build-system/shim/globby.mjs')
159+
}
160+
},
161+
define: {
162+
'process.env.NODE_DEBUG': 'false',
163+
'require.cache': '{}'
164+
}
165+
},
166+
167+
lastUpdated: true,
168+
themeConfig: {
169+
editLink: {
170+
pattern:
171+
'https://github.com/vuejs/eslint-plugin-vue/edit/master/docs/:path'
172+
},
173+
socialLinks: [
174+
{
175+
icon: 'github',
176+
link: 'https://github.com/vuejs/eslint-plugin-vue'
177+
}
178+
],
179+
180+
nav: [
181+
{ text: 'User Guide', link: '/user-guide/' },
182+
{ text: 'Developer Guide', link: '/developer-guide/' },
183+
{ text: 'Rules', link: '/rules/' },
184+
{
185+
text: 'Demo',
186+
link: 'https://ota-meshi.github.io/eslint-plugin-vue-demo/'
187+
}
188+
],
189+
190+
sidebar: {
191+
'/rules/': [
192+
{
193+
text: 'Rules',
194+
items: [{ text: 'Available Rules', link: '/rules/' }]
195+
},
196+
197+
// Rules in each category.
198+
...categorizedRules,
199+
200+
// Rules in no category.
201+
...extraCategories
202+
],
203+
204+
'/': [
205+
{
206+
text: 'Guide',
207+
items: [
208+
{ text: 'Introduction', link: '/' },
209+
{ text: 'User Guide', link: '/user-guide/' },
210+
{ text: 'Developer Guide', link: '/developer-guide/' },
211+
{ text: 'Rules', link: '/rules/' }
212+
]
213+
}
214+
]
215+
},
216+
217+
algolia: {
218+
appId: '2L4MGZSULB',
219+
apiKey: 'fdf57932b27a6c230d01a890492ab76d',
220+
indexName: 'eslint-plugin-vue'
221+
}
222+
}
223+
})
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// https://github.com/NekR/self-destroying-sw
2+
/* globals self */
3+
self.addEventListener('install', (e) => {
4+
self.skipWaiting()
5+
})
6+
7+
self.addEventListener('activate', (e) => {
8+
self.registration
9+
.unregister()
10+
.then(() => self.clients.matchAll())
11+
.then((clients) => {
12+
for (const client of clients) client.navigate(client.url)
13+
})
14+
})

0 commit comments

Comments
 (0)