ci: lint workflows (#19556)

This commit is contained in:
Daniel Roe 2023-03-09 11:34:41 +00:00 committed by GitHub
parent c8a5a4a487
commit eb1bb59542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 12 deletions

View File

@ -22,7 +22,6 @@ jobs:
- run: corepack enable
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: "pnpm"
- name: Install dependencies

25
.github/workflows/introspect.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: Docs
on:
push:
paths:
- ".github/workflows/**"
branches:
- main
pull_request:
paths:
- ".github/workflows/**"
branches:
- main
jobs:
lint-workflows:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# From https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions
- name: Check workflow files
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
./actionlint -color -shellcheck=""

View File

@ -93,7 +93,7 @@ Whether to run a separate build step.
#### `browser`
Under the hood, Nuxt test utils uses [`playwright`](https://playwright.dev/) to carry out browser testing. If this option is set, a browser will be launched and can be controlled in the subsequent test suite. (More info can be found [here](/docs/guide/going-further/testing).)
Under the hood, Nuxt test utils uses [`playwright`](https://playwright.dev/) to carry out browser testing. If this option is set, a browser will be launched and can be controlled in the subsequent test suite. (More info can be found [here](/docs/getting-started/testing).)
* Type: `boolean`
* Default: `false`

View File

@ -46,7 +46,7 @@ Any nested directories need to be added first as they are scanned in order.
## Component extensions
By default, any file with an extension specified in the [extensions key of `nuxt.config.ts`](/api/configuration/nuxt-config#extensions) is treated as a component.
By default, any file with an extension specified in the [extensions key of `nuxt.config.ts`](/docs/api/configuration/nuxt-config#extensions) is treated as a component.
If you need to restrict the file extensions that should be registered as components, you can use the extended form of the components directory declaration and its `extensions` key:
```diff

View File

@ -34,7 +34,7 @@ import { useNuxt } from '@nuxt/kit'
Nuxt Kit utilities are only available for modules and not meant to be imported in runtime (components, Vue composables, pages, plugins, or server routes).
::
Nuxt Kit is an [esm-only package](/docs/guide/going-further/esm) meaning that you **cannot** `require('@nuxt/kit')`. As a workaround, use dynamic import in the CommonJS context:
Nuxt Kit is an [esm-only package](/docs/guide/concepts/esm) meaning that you **cannot** `require('@nuxt/kit')`. As a workaround, use dynamic import in the CommonJS context:
```js [test.cjs]
// This does NOT work!

View File

@ -32,7 +32,7 @@ const submit = async () => {
}
```
::ReadMore{link="/docs/api/composables/navigate-to"}
::ReadMore{link="/docs/api/utils/navigate-to"}
::
::alert{icon=👉}

View File

@ -7,10 +7,10 @@ toc: false
This example shows how to test your Nuxt application.
::alert{type=info icon=👉}
Learn more about [testing](/docs/guide/going-further/testing).
Learn more about [testing](/docs/getting-started/testing).
::
::ReadMore{link="/docs/guide/going-further/testing"}
::ReadMore{link="/docs/getting-started/testing"}
::
::sandbox{repo="nuxt/nuxt" branch="main" dir="examples/advanced/testing" file="app.vue"}

View File

@ -10,7 +10,7 @@ const logger = consola.withTag('crawler')
const baseURL = withoutTrailingSlash(process.env.BASE_URL || 'https://nuxt.com')
const startingURL = baseURL + '/'
const excludedExtensions = ['svg', 'png', 'jpg', 'sketch', 'ico', 'gif']
const excludedExtensions = ['svg', 'png', 'jpg', 'sketch', 'ico', 'gif', 'zip']
const urlsToOmit = ['http://localhost:3000']
// TODO: remove when migrating to Nuxt 3/Docus
@ -27,6 +27,8 @@ const errorsToIgnore = [
const urls = new Set([startingURL])
const erroredUrls = new Set()
const referrers = new Map()
/**
* @param {string} path Path to check
* @param {string | undefined} referrer The referring page
@ -34,7 +36,7 @@ const erroredUrls = new Set()
function queue (path, referrer) {
if (!path) {
const message = chalk.red(`${chalk.bold('✗')} ${referrer} linked to empty href`)
if (isCI) { actions.error(message) }
if (isCI && path?.match(/\/docs\//)) { actions.error(message) }
logger.log(message)
return
}
@ -54,6 +56,7 @@ function queue (path, referrer) {
// Don't crawl external URLs
if (origin !== baseURL) { return }
referrers.set(url, referrer)
urls.add(url)
crawler.queue(url)
@ -68,12 +71,13 @@ const crawler = new Crawler({
const { statusCode } = res.request.response
if (error || ![200, 301, 302].includes(statusCode) || !$) {
if (errorsToIgnore.includes(parseURL(uri).pathname)) {
const message = chalk.gray(`${chalk.bold('✗')} ${uri} (${statusCode}) (ignored)`)
// TODO: normalize relative links in module readmes - https://github.com/nuxt/nuxt.com/issues/1271
if (errorsToIgnore.includes(parseURL(uri).pathname) || referrers.get(uri)?.match(/\/modules\//) || !uri?.match(/\/docs\//)) {
const message = chalk.gray(`${chalk.bold('✗')} ${uri} (${statusCode}) [<- ${referrers.get(uri)}] (ignored)`)
logger.log(message)
return done()
}
const message = chalk.red(`${chalk.bold('✗')} ${uri} (${statusCode})`)
const message = chalk.red(`${chalk.bold('✗')} ${uri} (${statusCode}) [<- ${referrers.get(uri)}]`)
if (isCI) { actions.error(message) }
logger.log(message)
erroredUrls.add(uri)