Skip to content

Commit 4acbd4f

Browse files
authored
feat: migrate from eslint-flat-config-viewer (#1)
1 parent d31dfc2 commit 4acbd4f

Some content is hidden

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

44 files changed

+11483
-0
lines changed

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v2
20+
21+
- name: Set node
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: lts/*
25+
26+
- name: Setup
27+
run: npm i -g @antfu/ni
28+
29+
- name: Install
30+
run: nci
31+
32+
- name: Lint
33+
run: nr lint
34+
35+
- name: Typecheck
36+
run: nr typecheck
37+
38+
test:
39+
runs-on: ${{ matrix.os }}
40+
41+
strategy:
42+
matrix:
43+
node: [lts/*]
44+
os: [ubuntu-latest, windows-latest, macos-latest]
45+
fail-fast: false
46+
47+
steps:
48+
- uses: actions/checkout@v3
49+
50+
- name: Install pnpm
51+
uses: pnpm/action-setup@v2
52+
53+
- name: Set node ${{ matrix.node }}
54+
uses: actions/setup-node@v3
55+
with:
56+
node-version: ${{ matrix.node }}
57+
58+
- name: Setup
59+
run: npm i -g @antfu/ni
60+
61+
- name: Install
62+
run: nci
63+
64+
- name: Build
65+
run: nr build
66+
67+
# - name: Test
68+
# run: nr test

.github/workflows/release-please.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: release-please
6+
jobs:
7+
release-please:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
id-token: write
13+
steps:
14+
- uses: google-github-actions/release-please-action@v3
15+
id: release
16+
with:
17+
release-type: node
18+
package-name: '@eslint/config-inspector'
19+
pull-request-title-pattern: 'chore: release ${version}'
20+
changelog-types: >
21+
[
22+
{ "type": "feat", "section": "Features", "hidden": false },
23+
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
24+
{ "type": "docs", "section": "Documentation", "hidden": false },
25+
{ "type": "build", "section": "Build Related", "hidden": false },
26+
{ "type": "chore", "section": "Chores", "hidden": false },
27+
{ "type": "perf", "section": "Chores", "hidden": false },
28+
{ "type": "ci", "section": "Chores", "hidden": false },
29+
{ "type": "refactor", "section": "Chores", "hidden": false },
30+
{ "type": "test", "section": "Chores", "hidden": false }
31+
]
32+
- uses: actions/checkout@v3
33+
if: ${{ steps.release.outputs.release_created }}
34+
- uses: actions/setup-node@v3
35+
with:
36+
node-version: lts/*
37+
registry-url: https://registry.npmjs.org
38+
if: ${{ steps.release.outputs.release_created }}
39+
- run: npm install
40+
if: ${{ steps.release.outputs.release_created }}
41+
- run: npm publish --provenance
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
if: ${{ steps.release.outputs.release_created }}
45+
- run: 'npx @humanwhocodes/tweet "@eslint/config-inspector ${{ steps.release.outputs.tag_name }} has been released: ${{ steps.release.outputs.html_url }}"'
46+
if: ${{ steps.release.outputs.release_created }}
47+
env:
48+
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
49+
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
50+
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
51+
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
52+
- run: 'npx @humanwhocodes/toot "@eslint/config-inspector ${{ steps.release.outputs.tag_name }} has been released: ${{ steps.release.outputs.html_url }}"'
53+
if: ${{ steps.release.outputs.release_created }}
54+
env:
55+
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
56+
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
*.log
3+
dist
4+
.output
5+
.nuxt
6+
.env
7+
.idea/

.npmrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
shamefully-hoist=true
2+
strict-peer-dependencies=false
3+
shell-emulator=true

.stackblitzrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"installDependencies": true,
3+
"startCommand": "npm run dev"
4+
}

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"recommendations": [
3+
"antfu.iconify",
4+
"antfu.unocss",
5+
"antfu.goto-alias",
6+
"csstools.postcss",
7+
"dbaeumer.vscode-eslint",
8+
"vue.volar"
9+
]
10+
}

.vscode/settings.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
// Enable the ESlint flat config support
3+
"eslint.experimental.useFlatConfig": true,
4+
5+
// Disable the default formatter, use eslint instead
6+
"prettier.enable": false,
7+
"editor.formatOnSave": false,
8+
9+
// Auto fix
10+
"editor.codeActionsOnSave": {
11+
"source.fixAll": "explicit",
12+
"source.organizeImports": "never"
13+
},
14+
15+
// Silent the stylistic rules in you IDE, but still auto fix them
16+
"eslint.rules.customizations": [
17+
{ "rule": "style/*", "severity": "off" },
18+
{ "rule": "*-indent", "severity": "off" },
19+
{ "rule": "*-spacing", "severity": "off" },
20+
{ "rule": "*-spaces", "severity": "off" },
21+
{ "rule": "*-order", "severity": "off" },
22+
{ "rule": "*-dangle", "severity": "off" },
23+
{ "rule": "*-newline", "severity": "off" },
24+
{ "rule": "*quotes", "severity": "off" },
25+
{ "rule": "*semi", "severity": "off" }
26+
],
27+
28+
// Enable eslint for all supported languages
29+
"eslint.validate": [
30+
"javascript",
31+
"javascriptreact",
32+
"typescript",
33+
"typescriptreact",
34+
"vue",
35+
"html",
36+
"markdown",
37+
"json",
38+
"jsonc",
39+
"yaml"
40+
]
41+
}

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<img src="./public/favicon.svg" width="100" height="100"><br>
2+
3+
# ESLint Config Inspector
4+
5+
[![npm version][npm-version-src]][npm-version-href]
6+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
7+
8+
A visual tool to help you view and understand your [ESLint Flat configs](https://eslint.org/docs/latest/use/configure/configuration-files-new).
9+
10+
<img width="1199" alt="Screenshot" src="https://github.com/antfu/eslint-flat-config-viewer/assets/11247099/f386563a-c655-458e-a2c3-0af19ebec958">
11+
<img width="1199" alt="Screenshot" src="https://github.com/antfu/eslint-flat-config-viewer/assets/11247099/44edeb05-02b3-4bca-8da6-768984e8d829">
12+
13+
## Usage
14+
15+
Change the directory to your project root that contains `eslint.config.js` and run:
16+
17+
```bash
18+
npx @eslint/config-inspector
19+
```
20+
21+
Goto http://localhost:7777/ to view your ESLint config. Whenever you update your ESLint config, the page will be updated automatically.
22+
23+
---
24+
25+
Or play it in your browser:
26+
27+
[![](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/~/github.com/eslint/config-inspector)
28+
29+
## License
30+
31+
[Apache-2.0](./LICENSE) License
32+
33+
<!-- Badges -->
34+
35+
[npm-version-src]: https://img.shields.io/npm/v/eslint-flat-config-viewer?style=flat&colorA=080f12&colorB=1fa669
36+
[npm-version-href]: https://npmjs.com/package/eslint-flat-config-viewer
37+
[npm-downloads-src]: https://img.shields.io/npm/dm/eslint-flat-config-viewer?style=flat&colorA=080f12&colorB=1fa669
38+
[npm-downloads-href]: https://npmjs.com/package/eslint-flat-config-viewer

app.vue

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<script setup lang="ts">
2+
import { useHead } from '@unhead/vue'
3+
import { errorInfo } from './composables/payload'
4+
import 'floating-vue/dist/style.css'
5+
import './styles/global.css'
6+
import './composables/dark'
7+
import { version } from './package.json'
8+
import { ensureDataFetch } from '~/composables/payload'
9+
10+
useHead({
11+
title: 'ESLint Config Inspector',
12+
})
13+
14+
await ensureDataFetch()
15+
</script>
16+
17+
<template>
18+
<div v-if="errorInfo" grid h-full w-full place-content-center whitespace-pre-line>
19+
<div font-200 text-xl mb6>
20+
<a
21+
href="https://github.com/eslint/config-inspector" target="_blank"
22+
flex="inline gap-2 items-center" mr1
23+
>
24+
<img src="/favicon.svg" inline-block h-1em>
25+
<span op75>ESLint Config Inspector</span>
26+
</a>
27+
<sup op50>v{{ version }}</sup>
28+
</div>
29+
30+
<div text-2xl text-red5 font-bold>
31+
Failed to load <span rounded bg-red:5 px2>eslint.config.js</span><br>
32+
</div>
33+
34+
<div text-lg text-red font-mono>
35+
{{ errorInfo.error }}
36+
</div>
37+
38+
<div op50 mt6>
39+
Note that
40+
<a href="https://github.com/eslint/config-inspector" target="_blank" hover:underline>config inspector</a>
41+
only works with the <a href="https://eslint.org/docs/latest/use/configure/configuration-files-new" target="_blank" font-bold hover:underline>flat config format</a>.
42+
</div>
43+
</div>
44+
<div v-else px14 py10>
45+
<NavBar />
46+
<NuxtPage />
47+
</div>
48+
</template>

bin.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env node
2+
3+
import process from 'node:process'
4+
import open from 'open'
5+
import { getPort } from 'get-port-please'
6+
7+
process.env.HOST = process.env.HOST || '127.0.0.1'
8+
process.env.PORT = process.env.PORT || await getPort({ port: 7777 })
9+
10+
await Promise.all([
11+
import('./dist/server/index.mjs'),
12+
process.env.NO_OPEN
13+
? undefined
14+
: open(`http://localhost:${process.env.PORT}`),
15+
])

components/ColorizedConfigName.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export default defineComponent({
2+
props: {
3+
name: {
4+
type: String,
5+
required: true,
6+
},
7+
},
8+
setup(props) {
9+
const parts = computed(() => props.name.split(/([:/])/g).filter(Boolean))
10+
return () => h('span', parts.value.map((part, i) => {
11+
return h(
12+
'span',
13+
[':', '/'].includes(part)
14+
? { style: { opacity: 0.4 } }
15+
: i !== parts.value.length - 1
16+
? { style: { color: getPluginColor(part) } }
17+
: null,
18+
part,
19+
)
20+
}))
21+
},
22+
})

components/ColorizedRuleName.vue

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<script setup lang="ts">
2+
import { computed } from 'vue'
3+
4+
const props = defineProps<{
5+
name: string
6+
prefix?: string
7+
url?: string
8+
as?: string
9+
deprecated?: boolean
10+
borderless?: boolean
11+
break?: boolean
12+
}>()
13+
14+
const parsed = computed(() => {
15+
if (props.prefix) {
16+
if (props.name.startsWith(props.prefix)) {
17+
return {
18+
scope: props.prefix,
19+
name: props.name.slice(props.prefix.length).replace(/^\/+/, ''),
20+
}
21+
}
22+
else {
23+
return {
24+
scope: undefined,
25+
name: props.name,
26+
}
27+
}
28+
}
29+
const parts = props.name.split('/')
30+
if (parts.length === 1) {
31+
return {
32+
scope: undefined,
33+
name: parts[0],
34+
}
35+
}
36+
return {
37+
scope: parts[0],
38+
name: parts.slice(1).join('/'),
39+
}
40+
})
41+
</script>
42+
43+
<template>
44+
<component
45+
:is="as || 'div'"
46+
ws-nowrap font-mono of-hidden text-ellipsis
47+
:class="[
48+
deprecated ? 'line-through' : '',
49+
borderless ? '' : 'border border-base px2 bg-gray:5 rounded',
50+
]"
51+
>
52+
<span v-if="parsed.scope" :style="{ color: getPluginColor(parsed.scope) }">{{ parsed.scope }}</span>
53+
<span v-if="parsed.scope" op30>/</span>
54+
<br v-if="parsed.scope && props.break">
55+
<span op75>{{ parsed.name }}</span>
56+
</component>
57+
</template>

0 commit comments

Comments
 (0)