Skip to content

Commit 3b2fd6e

Browse files
antfu9romise
andauthored
feat!: v5: remove sub packages (#794)
Co-authored-by: Vida Xie <[email protected]>
1 parent 0a22599 commit 3b2fd6e

514 files changed

Lines changed: 703 additions & 17938 deletions

File tree

Some content is hidden

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

alias.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ export const aliasVirtual = {
88

99
export const alias = {
1010
'@stylistic/eslint-plugin': fileURLToPath(new URL('./packages/eslint-plugin/src/index.ts', import.meta.url)),
11-
'@stylistic/eslint-plugin-js': fileURLToPath(new URL('./packages/eslint-plugin-js/src/index.ts', import.meta.url)),
12-
'@stylistic/eslint-plugin-jsx': fileURLToPath(new URL('./packages/eslint-plugin-jsx/src/index.ts', import.meta.url)),
13-
'@stylistic/eslint-plugin-ts': fileURLToPath(new URL('./packages/eslint-plugin-ts/src/index.ts', import.meta.url)),
14-
'@stylistic/eslint-plugin-plus': fileURLToPath(new URL('./packages/eslint-plugin-plus/src/index.ts', import.meta.url)),
1511
'@eslint-stylistic/metadata': fileURLToPath(new URL('./packages/metadata/src/index.ts', import.meta.url)),
1612
...aliasVirtual,
1713
}

docs/.vitepress/components/RuleItem.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
<script setup lang="ts">
22
import type { PackageInfo, RuleInfo } from '@eslint-stylistic/metadata'
3-
import { computed } from 'vue'
43
5-
const props = defineProps<{
4+
defineProps<{
65
rule: RuleInfo
76
package: PackageInfo
87
}>()
9-
10-
const shortId = computed(() => props.package.shortId)
118
</script>
129

1310
<template>
1411
<tr>
1512
<td>
16-
<a :href="`/rules/${shortId}/${rule.name}`" class="decoration-none!">
13+
<a :href="`/rules/${rule.name}`" class="decoration-none!">
1714
<code ws-nowrap>
1815
{{ rule.name }}
1916
</code>

docs/.vitepress/config.ts

Lines changed: 11 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,27 @@
22
import type { ESLint, Linter } from 'eslint'
33
import type { DefaultTheme } from 'vitepress'
44
import fs from 'node:fs/promises'
5-
import { basename, dirname, join } from 'node:path'
5+
import { join } from 'node:path'
66
import { fileURLToPath } from 'node:url'
77
import { transformerRenderWhitespace } from '@shikijs/transformers'
88
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
99
import stylistic from '@stylistic/eslint-plugin'
10-
import stylisticJs from '@stylistic/eslint-plugin-js'
11-
import stylisticJsx from '@stylistic/eslint-plugin-jsx'
12-
import stylisticPlus from '@stylistic/eslint-plugin-plus'
13-
import stylisticTs from '@stylistic/eslint-plugin-ts'
1410
import * as parserTs from '@typescript-eslint/parser'
1511
import MarkdownItContainer from 'markdown-it-container'
1612
import { createTwoslasher } from 'twoslash-eslint'
1713
import { defineConfig } from 'vitepress'
1814
import { packages } from '../../packages/metadata/src'
1915
import vite from './vite.config'
2016

21-
const mainPackages = packages.filter(p => p.rules.length)
22-
const defaultPackage = packages.find(p => p.shortId === 'default')!
23-
const jsPackage = packages.find(p => p.shortId === 'js')!
24-
const tsPackage = packages.find(p => p.shortId === 'ts')!
17+
const mainPackages = packages[0]
2518
const projectRoot = fileURLToPath(new URL('../..', import.meta.url))
2619
const version = JSON.parse(await fs.readFile(join(projectRoot, 'package.json'), 'utf-8')).version
2720

2821
const GUIDES: DefaultTheme.NavItemWithLink[] = [
2922
{ text: 'Getting Started', link: '/guide/getting-started' },
3023
{ text: 'Why', link: '/guide/why' },
3124
{ text: 'Shared Configs', link: '/guide/config-presets' },
25+
{ text: 'Rules', link: '/rules' },
3226
{ text: 'Migration', link: '/guide/migration' },
3327
{ text: 'FAQ', link: '/guide/faq' },
3428
]
@@ -38,98 +32,22 @@ const CONTRIBUTES: DefaultTheme.NavItemWithLink[] = [
3832
{ text: 'Contributing', link: '/contribute/guide' },
3933
]
4034

41-
const PACKAGES: DefaultTheme.NavItemWithLink[] = [
42-
{ text: 'Default', link: '/packages/default' },
43-
{ text: 'JavaScript', link: '/packages/js' },
44-
{ text: 'TypeScript', link: '/packages/ts' },
45-
{ text: 'JSX', link: '/packages/jsx' },
46-
{ text: 'Additional', link: '/packages/plus' },
47-
]
48-
4935
const VERSIONS: DefaultTheme.NavItemWithLink[] = [
5036
{ text: `v${version} (current)`, link: '/' },
37+
{ text: `v4.x`, link: 'https://v4.eslint.style/', target: '_blank' },
5138
{ text: `Release Notes`, link: 'https://github.com/eslint-stylistic/eslint-stylistic/releases' },
5239
{ text: `Contributing`, link: '/contribute/guide' },
5340
]
5441

55-
const packageNames: Record<string, string> = {
56-
default: 'All Rules',
57-
js: 'JavaScript Rules',
58-
ts: 'TypeScript Rules',
59-
jsx: 'JSX Rules',
60-
extra: 'Additional Rules',
61-
}
62-
63-
// Because VitePress does not support rewrite single source to multiple targets,
64-
// we have to duplicate the markdown files for the aliases.
65-
await Promise.all(
66-
defaultPackage.rules.map(async (rule) => {
67-
const newPath = join(
68-
dirname(rule.docsEntry),
69-
`${basename(rule.docsEntry, '.md').replace(/\._\w+_$/, '')}._merged_.md`,
70-
)
71-
const jsEntry = jsPackage.rules.find(r => r.name === rule.name)
72-
const tsEntry = tsPackage.rules.find(r => r.name === rule.name)
73-
if (tsEntry && jsEntry) {
74-
const tsContent = (await fs.readFile(
75-
join(projectRoot, tsEntry.docsEntry),
76-
'utf-8',
77-
))
78-
// Remove frontmatter
79-
.replace(/^---[\s\S]*?\n---\n/, '')
80-
.trim()
81-
.split(/\r?\n/g)
82-
// Remove lines redirecting to the JS rule, as we already have them above
83-
.filter(l => !l.startsWith('This rule extends the base') && !l.startsWith('It adds support for '))
84-
// Adding one level of heading
85-
.map(i => i.startsWith('#') ? `#${i}` : i)
86-
.join('\n')
87-
.trim()
88-
if (tsContent) {
89-
const jsContent = await fs.readFile(
90-
join(projectRoot, jsEntry.docsEntry),
91-
'utf-8',
92-
)
93-
const content = [
94-
jsContent,
95-
'',
96-
'## TypeScript Specific',
97-
'',
98-
tsContent,
99-
]
100-
await fs.writeFile(
101-
join(projectRoot, newPath),
102-
content.join('\n'),
103-
)
104-
}
105-
else {
106-
await fs.copyFile(
107-
join(projectRoot, jsEntry.docsEntry),
108-
join(projectRoot, newPath),
109-
)
110-
}
111-
}
112-
else {
113-
// console.log('No JS or TS entry found for', rule.name)
114-
await fs.copyFile(
115-
join(projectRoot, rule.docsEntry),
116-
join(projectRoot, newPath),
117-
)
118-
}
119-
rule.docsEntry = newPath
120-
}),
121-
)
122-
12342
// https://vitepress.dev/reference/site-config
12443
export default defineConfig({
12544
title: 'ESLint Stylistic',
12645
description: 'Stylistic & Formatting Rules for ESLint',
12746
rewrites: {
128-
// rewrite rules to /rules/js/:name
12947
...Object.fromEntries(
13048
packages
13149
.flatMap(pkg => pkg.rules
132-
.map(r => [r.docsEntry, `rules/${pkg.shortId}/${r.name}.md`])),
50+
.map(r => [r.docsEntry, `rules/${r.name}.md`])),
13351
),
13452
// rewrite docs markdown because we set the `srcDir` to the root of the monorepo
13553
'docs/:name(.+).md': ':name.md',
@@ -185,10 +103,6 @@ export default defineConfig({
185103
files: ['**'],
186104
plugins: {
187105
'@stylistic': stylistic as ESLint.Plugin,
188-
'@stylistic/js': stylisticJs as ESLint.Plugin,
189-
'@stylistic/jsx': stylisticJsx as ESLint.Plugin,
190-
'@stylistic/ts': stylisticTs as ESLint.Plugin,
191-
'@stylistic/plus': stylisticPlus as ESLint.Plugin,
192106
},
193107
languageOptions: {
194108
parser: parserTs as Linter.Parser,
@@ -221,10 +135,6 @@ export default defineConfig({
221135
},
222136
],
223137
},
224-
{
225-
text: 'Packages',
226-
items: PACKAGES,
227-
},
228138
{
229139
text: 'Rules',
230140
link: '/rules',
@@ -236,24 +146,12 @@ export default defineConfig({
236146
],
237147

238148
sidebar: Object.assign(
239-
{},
240-
...mainPackages.map((pkg) => {
241-
return {
242-
[`/rules/${pkg.shortId}/`]: [
243-
{
244-
text: 'Packages',
245-
items: PACKAGES,
246-
},
247-
{
248-
text: packageNames[pkg.shortId] || pkg.name,
249-
items: pkg.rules.map((rule): DefaultTheme.SidebarItem => ({
250-
text: rule.name,
251-
link: `/rules/${pkg.shortId}/${rule.name}`,
252-
})),
253-
},
254-
],
255-
}
256-
}),
149+
{
150+
'/rules/': mainPackages.rules.map((rule): DefaultTheme.SidebarItem => ({
151+
text: rule.name,
152+
link: `/rules/${rule.name}`,
153+
})),
154+
},
257155
{
258156
'/': [
259157
{
@@ -264,10 +162,6 @@ export default defineConfig({
264162
text: 'Contribute',
265163
items: CONTRIBUTES,
266164
},
267-
{
268-
text: 'Packages',
269-
items: PACKAGES,
270-
},
271165
],
272166
},
273167
),

docs/guide/getting-started.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,20 @@
22

33
ESLint Stylistic is a collection of stylistic rules for ESLint, migrated from `eslint` core and `@typescript-eslint` repo to shift the maintenance effort to the community. Learn more about [why we need this project](/guide/why).
44

5-
## Packages
5+
## Plugin
66

7-
ESLint Stylistic is composed of 4 plugins and 1 unified plugin:
7+
ESLint Stylistic is provided as a unified plugin, which supports supports JS, TS and JSX out of the box.
88

9-
### Migrated plugins
9+
[Check the rules and install guide](/rules) for more details.
1010

11-
- `eslint` -> [`@stylistic/eslint-plugin-js`](/packages/js)
12-
- Built-in stylistic rules for JavaScript
13-
- `@typescript-eslint/eslint-plugin` -> [`@stylistic/eslint-plugin-ts`](/packages/ts)
14-
- Stylistic rules for TypeScript
15-
- `eslint-plugin-react` -> [`@stylistic/eslint-plugin-jsx`](/packages/jsx)
16-
- Stylistic rules for framework-agnostic JSX
11+
:::info Unified Plugin
1712

18-
### Additional plugins
13+
We used to provide separate plugins for each language like `@stylistic/eslint-plugin-js`, but **since v5**, we have merged them into a single plugin.
1914

20-
- [`@stylistic/eslint-plugin-plus`](/packages/plus)
21-
- Supplementary rules introduced by ESLint Stylistic
15+
Those separated plugins would still work but would not receive new features. Please consider migrating to the unified plugin.
2216

23-
### Unified plugins
17+
The legacy docs is available at [v4.eslint.style](https://v4.eslint.style/).
2418

25-
- [`@stylistic/eslint-plugin`](/packages/default)
26-
- All rules from the above 4 plugins
27-
28-
<br>
29-
30-
::: tip
31-
Check the [project progress](/contribute/project-progress) first to learn more about the current status of this project.
3219
:::
3320

3421
## Migration

0 commit comments

Comments
 (0)