diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index d593e239e..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,86 +0,0 @@ -workflows: - version: 2 - node-multi-build: - jobs: - - node-v8 - - node-v10 - - node-v12 - - node-v14 - - lint - -version: 2 -jobs: - node-base: &node-base - docker: - - image: node - steps: - - run: - name: Versions - command: npm version - - checkout - - restore_cache: - keys: - - v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} - - run: - name: Install dependencies - command: npm install - - save_cache: - key: v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} - paths: - - node_modules - - run: - name: Test - command: npm test - - node-v8: - docker: - - image: node:8 - steps: - - run: - name: Versions - command: npm version - - checkout - - run: - name: Install eslint@6 - command: | - npm install -D eslint@6.2.0 - - run: - name: Install dependencies - command: npm install - - run: - name: Test - command: npm test - node-v10: - <<: *node-base - docker: - - image: node:10 - node-v12: - <<: *node-base - docker: - - image: node:12 - node-v14: - <<: *node-base - docker: - - image: node:14 - - lint: - docker: - - image: node:14 - steps: - - run: - name: Versions - command: npm version - - checkout - - restore_cache: - keys: - - v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} - - run: - name: Install dependencies - command: npm install - - save_cache: - key: v2-npm-lock-{{ .Branch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }} - paths: - - node_modules - - run: - name: Test - command: npm run lint diff --git a/.env-cmdrc b/.env-cmdrc new file mode 100644 index 000000000..59d3db357 --- /dev/null +++ b/.env-cmdrc @@ -0,0 +1,5 @@ +{ + "version": { + "IN_VERSION_SCRIPT": "true" + } +} diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 1905aa4a8..000000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -/.nyc_output -/coverage -/node_modules -/tests/fixtures -/tests/integrations/eslint-plugin-import - -!.vuepress -/docs/.vuepress/dist diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 704f09732..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,144 +0,0 @@ -'use strict' - -module.exports = { - root: true, - parserOptions: { - ecmaVersion: 2018 - }, - env: { - es6: true, - node: true, - mocha: true - }, - extends: ['plugin:eslint-plugin/recommended', 'prettier'], - plugins: ['eslint-plugin', 'prettier'], - rules: { - 'accessor-pairs': 2, - camelcase: [2, { properties: 'never' }], - 'constructor-super': 2, - eqeqeq: [2, 'allow-null'], - 'handle-callback-err': [2, '^(err|error)$'], - 'jsx-quotes': [2, 'prefer-single'], - 'new-cap': [2, { newIsCap: true, capIsNew: false }], - 'new-parens': 2, - 'no-array-constructor': 2, - 'no-caller': 2, - 'no-class-assign': 2, - 'no-cond-assign': 2, - 'no-const-assign': 2, - 'no-control-regex': 2, - 'no-delete-var': 2, - 'no-dupe-args': 2, - 'no-dupe-class-members': 2, - 'no-dupe-keys': 2, - 'no-duplicate-case': 2, - 'no-empty-character-class': 2, - 'no-empty-pattern': 2, - 'no-eval': 2, - 'no-ex-assign': 2, - 'no-extend-native': 2, - 'no-extra-bind': 2, - 'no-extra-boolean-cast': 2, - 'no-extra-parens': [2, 'functions'], - 'no-fallthrough': 2, - 'no-floating-decimal': 2, - 'no-func-assign': 2, - 'no-implied-eval': 2, - 'no-inner-declarations': [2, 'functions'], - 'no-invalid-regexp': 2, - 'no-irregular-whitespace': 2, - 'no-iterator': 2, - 'no-label-var': 2, - 'no-labels': [2, { allowLoop: false, allowSwitch: false }], - 'no-lone-blocks': 2, - 'no-multi-spaces': [2, { ignoreEOLComments: true }], - 'no-multi-str': 2, - 'no-native-reassign': 2, - 'no-negated-in-lhs': 2, - 'no-new-object': 2, - 'no-new-require': 2, - 'no-new-symbol': 2, - 'no-new-wrappers': 2, - 'no-obj-calls': 2, - 'no-octal': 2, - 'no-octal-escape': 2, - 'no-path-concat': 2, - 'no-proto': 2, - 'no-redeclare': 2, - 'no-regex-spaces': 2, - 'no-return-assign': [2, 'except-parens'], - 'no-self-assign': 2, - 'no-self-compare': 2, - 'no-sequences': 2, - 'no-shadow-restricted-names': 2, - 'no-sparse-arrays': 2, - 'no-this-before-super': 2, - 'no-throw-literal': 2, - 'no-undef': 2, - 'no-undef-init': 2, - 'no-unexpected-multiline': 2, - 'no-unmodified-loop-condition': 2, - 'no-unneeded-ternary': [2, { defaultAssignment: false }], - 'no-unreachable': 2, - 'no-unsafe-finally': 2, - 'no-unused-vars': [2, { vars: 'all', args: 'none' }], - 'no-useless-call': 2, - 'no-useless-computed-key': 2, - 'no-useless-constructor': 2, - 'no-useless-escape': 0, - 'no-with': 2, - 'one-var': [2, { initialized: 'never' }], - 'use-isnan': 2, - 'valid-typeof': 2, - 'wrap-iife': [2, 'any'], - yoda: [2, 'never'], - 'prefer-const': 2, - - 'prettier/prettier': 'error', - 'eslint-plugin/report-message-format': ['error', "^[A-Z`'{].*\\.$"], - 'eslint-plugin/prefer-placeholders': 'error', - 'eslint-plugin/consistent-output': 'error', - - 'no-debugger': 'error', - 'no-console': 'error', - 'no-alert': 'error', - 'no-void': 'error', - - 'no-warning-comments': 'warn', - 'no-var': 'error', - 'prefer-template': 'error', - 'object-shorthand': 'error', - 'prefer-rest-params': 'error', - 'prefer-arrow-callback': 'error', - 'prefer-spread': 'error', - - 'dot-notation': 'error' - }, - overrides: [ - { - files: ['./**/*.vue'], - parser: require.resolve('vue-eslint-parser'), - parserOptions: { - ecmaVersion: 2020, - sourceType: 'module' - } - }, - { - files: ['lib/rules/*.js'], - rules: { - 'consistent-docs-description': 'error', - 'no-invalid-meta': 'error', - 'no-invalid-meta-docs-categories': 'error', - 'eslint-plugin/require-meta-type': 'error', - 'require-meta-docs-url': [ - 'error', - { - pattern: `https://eslint.vuejs.org/rules/{{name}}.html` - } - ], - - 'eslint-plugin/fixer-return': 'off' - } - } - ] -} diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..c4d031e9c --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +github: + - ota-meshi + - FloEdelmann diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 94800468f..08d755127 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,6 +3,13 @@ name: Bug report about: Create a report to help us improve --- + + **Tell us about your environment** - **ESLint version:** - **eslint-plugin-vue version:** +- **Vue version:** - **Node version:** - **Operating System:** **Please show your full configuration:** -```json +```json5 ``` @@ -42,4 +52,9 @@ about: Create a report to help us improve --> **Repository to reproduce this issue** + diff --git a/.github/ISSUE_TEMPLATE/change.md b/.github/ISSUE_TEMPLATE/change.md index a6a4a7dc0..02397f6cd 100644 --- a/.github/ISSUE_TEMPLATE/change.md +++ b/.github/ISSUE_TEMPLATE/change.md @@ -13,6 +13,7 @@ about: Request a change that is not a bug fix, rule change, or new rule - **ESLint version:** - **eslint-plugin-vue version:** +- **Vue version:** - **Node version:** **The problem you want to solve.** diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..57aa5876d --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,68 @@ +name: CI +on: + push: + branches: + - 'master' + pull_request: + types: + - 'opened' + - 'synchronize' + - 'reopened' + +permissions: + contents: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js + uses: actions/setup-node@v4 + - name: Install Packages + run: npm install --legacy-peer-deps + - name: Lint + run: npm run lint + + test: + name: Test + strategy: + matrix: + node: [18, 20, 21, 'lts/*'] + eslint: [9] + include: + # On old ESLint version + - node: 18 + eslint: 8 + + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js v${{ matrix.node }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node }} + - name: Install Packages + run: npm install -f + - name: Install ESLint v${{ matrix.eslint }} + run: npm install --save-dev eslint@${{ matrix.eslint }} -f + - name: Test + run: npm test + + test-without-eslint-stylistic: + name: Test without ESLint Stylistic + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js + uses: actions/setup-node@v4 + - name: Install Packages + run: npm install -f + - name: Uninstall @stylistic/eslint-plugin + run: npm uninstall -D @stylistic/eslint-plugin + - name: Test + run: npm test diff --git a/.github/workflows/check-for-resources-update.yml b/.github/workflows/check-for-resources-update.yml new file mode 100644 index 000000000..31f881b1d --- /dev/null +++ b/.github/workflows/check-for-resources-update.yml @@ -0,0 +1,31 @@ +name: Check for utils resources update +on: + workflow_dispatch: null + schedule: + - cron: 0 0 * * 0 # At 00:00 on Sunday, see https://crontab.guru/#0_0_*_*_0 + +permissions: + contents: write + pull-requests: write + +jobs: + check-for-resources-update: + runs-on: ubuntu-latest + if: ${{ github.repository == 'vuejs/eslint-plugin-vue' }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install Packages + run: npm install + - name: Update + run: npm run update-resources + - uses: peter-evans/create-pull-request@v7 + with: + commit-message: Updates resources + branch: update-resources + branch-suffix: timestamp + title: Updates resources diff --git a/.gitignore b/.gitignore index e1401b951..797d0cbcd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,9 @@ /test.* yarn.lock yarn-error.log -docs/.vuepress/dist +/docs/.vitepress/dist +/docs/.vitepress/build-system/shim/eslint.mjs +/docs/.vitepress/build-system/shim/assert.mjs +/docs/.vitepress/.temp +/docs/.vitepress/cache typings/eslint/lib/rules diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 000000000..6591a3543 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,26 @@ +line-length: false +link-fragments: false +single-title: false +no-inline-html: + allowed_elements: + - badge + - eslint-code-block + - sup + - rules-table + - span + +# enforce consistency +code-block-style: + style: fenced +code-fence-style: + style: backtick +emphasis-style: + style: underscore +heading-style: + style: atx +hr-style: + style: --- +strong-style: + style: asterisk +ul-style: + style: dash diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1 @@ +node_modules diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..d341f1772 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +tests/fixtures/ +.github/ISSUE_TEMPLATE/*.md diff --git a/.vscode/launch.json b/.vscode/launch.json index 324a79864..2fa4db9b2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,10 +6,7 @@ "request": "launch", "name": "Start testing", "program": "${workspaceFolder}/node_modules/.bin/mocha", - "args": [ - "${file}", - "--watch" - ], + "args": ["${file}", "--watch"], "console": "integratedTerminal" } ] diff --git a/.vscode/settings.json b/.vscode/settings.json index e8e944bef..f80681b66 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,13 +1,15 @@ { - "editor.tabSize": 2, - "eslint.options": { - "rulePaths": ["eslint-internal-rules"] - }, - "eslint.validate": [ - "javascript", - "javascriptreact", - "vue" - ], - "typescript.tsdk": "node_modules/typescript/lib", - "vetur.validation.script": false + "editor.tabSize": 2, + "eslint.experimental.useFlatConfig": true, + "eslint.validate": ["javascript", "javascriptreact", "vue", "json", "jsonc"], + "typescript.tsdk": "./node_modules/typescript/lib", + "vetur.validation.script": false, + "[typescript]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[javascript]": { + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" + } } diff --git a/README.md b/README.md index 52fb216ef..bdeb5e167 100644 --- a/README.md +++ b/README.md @@ -2,63 +2,54 @@ [![NPM version](https://img.shields.io/npm/v/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue) [![NPM downloads](https://img.shields.io/npm/dm/eslint-plugin-vue.svg?style=flat)](https://npmjs.org/package/eslint-plugin-vue) -[![CircleCI](https://img.shields.io/circleci/project/github/vuejs/eslint-plugin-vue/master.svg?style=flat)](https://circleci.com/gh/vuejs/eslint-plugin-vue) -[![License](https://img.shields.io/github/license/vuejs/eslint-plugin-vue.svg?style=flat)](https://github.com/vuejs/eslint-plugin-vue/blob/master/LICENSE.md) +[![CI](https://img.shields.io/github/actions/workflow/status/vuejs/eslint-plugin-vue/CI.yml?style=flat&label=CI)](https://github.com/vuejs/eslint-plugin-vue/actions/workflows/CI.yml) +[![License](https://img.shields.io/github/license/vuejs/eslint-plugin-vue.svg?style=flat)](https://github.com/vuejs/eslint-plugin-vue/blob/master/LICENSE) > Official ESLint plugin for Vue.js ## :book: Documentation -See [the official website](https://eslint.vuejs.org). - -> :exclamation: Attention - this is documentation for version `7.x` :exclamation: -> -> This branch contains `eslint-plugin-vue@next` which is a pre-released `7.0`, but it's not the default version that you get with `npm install eslint-plugin-vue`. In order to install this you need to specify either `"eslint-plugin-vue": "next"` in `package.json` or do `npm install eslint-plugin-vue@next`. -> -> Please try it and report any issues that you might have encountered. -> -> If you want to check previous releases [go here](https://github.com/vuejs/eslint-plugin-vue/releases). +Please refer to the [official website](https://eslint.vuejs.org). ## :anchor: Versioning Policy -This plugin is following [Semantic Versioning](https://semver.org/) and [ESLint's Semantic Versioning Policy](https://github.com/eslint/eslint#semantic-versioning-policy). +This plugin follows [Semantic Versioning]. +However, please note that we do not follow [ESLint's Semantic Versioning Policy]. +In minor version releases, this plugin may change the sharable configs provided by the plugin or the default behavior of the plugin's rules in order to add features to the plugin. Because we want to add many features to the plugin soon, so that users can easily take advantage of new features in Vue and Nuxt. -## :newspaper: Changelog +According to our policy, any minor update may report more linting errors than the previous release. As such, we recommend using the [tilde (`~`)](https://semver.npmjs.com/#syntax-examples) in `package.json` to guarantee the results of your builds. -This project uses [GitHub Releases](https://github.com/vuejs/eslint-plugin-vue/releases). +[Semantic Versioning]: https://semver.org/ +[ESLint's Semantic Versioning Policy]: https://github.com/eslint/eslint#semantic-versioning-policy -## :beers: Contribution Guide +## :newspaper: Releases -Contribution is welcome! +This project uses [GitHub Releases](https://github.com/vuejs/eslint-plugin-vue/releases). -See [The ESLint Vue Plugin Developer Guide](https://eslint.vuejs.org/developer-guide/). +## :beers: Contribution Guide -### Working with Rules +Contributing is welcome! See the [ESLint Vue Plugin Developer Guide](https://eslint.vuejs.org/developer-guide). -Before you start writing a new rule, please read [the official ESLint guide](https://eslint.org/docs/developer-guide/working-with-rules). +### Working With Rules -Next, in order to get an idea how does the AST of the code that you want to check looks like, use the [astexplorer.net]. -The [astexplorer.net] is a great tool to inspect ASTs, also Vue templates are supported. +Be sure to read the [official ESLint guide](https://eslint.org/docs/developer-guide/working-with-rules) before you start writing a new rule. -After opening [astexplorer.net], select `Vue` as the syntax and `vue-eslint-parser` as the parser. +To see what an abstract syntax tree (AST) of your code looks like, you may use [AST Explorer](https://astexplorer.net). After opening [AST Explorer](https://astexplorer.net), select `Vue` as the syntax and `vue-eslint-parser` as the parser. -[astexplorer.net]: https://astexplorer.net/ +The default JavaScript parser must be replaced because [Vue.js single file components](https://vuejs.org/guide/scaling-up/sfc.html) are not plain JavaScript, but a custom file format. [`vue-eslint-parser`](https://github.com/vuejs/vue-eslint-parser) is a replacement parser that generates an enhanced AST with nodes that represent specific parts of the template syntax, as well as the contents of the ` + + + + diff --git a/docs/.vitepress/theme/components/eslint-code-block.vue b/docs/.vitepress/theme/components/eslint-code-block.vue new file mode 100644 index 000000000..77d4fd7cf --- /dev/null +++ b/docs/.vitepress/theme/components/eslint-code-block.vue @@ -0,0 +1,234 @@ + + + + + diff --git a/docs/.vitepress/theme/components/rules-table.vue b/docs/.vitepress/theme/components/rules-table.vue new file mode 100644 index 000000000..c517d4591 --- /dev/null +++ b/docs/.vitepress/theme/components/rules-table.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts new file mode 100644 index 000000000..757e63cab --- /dev/null +++ b/docs/.vitepress/theme/index.ts @@ -0,0 +1,32 @@ +// @ts-expect-error -- Browser +if (typeof window !== 'undefined') { + if (typeof require === 'undefined') { + // @ts-expect-error -- Browser + ;(window as any).require = () => { + const e = new Error('require is not defined') + ;(e as any).code = 'MODULE_NOT_FOUND' + throw e + } + } +} +// @ts-expect-error -- Cannot change `module` option +import type { Theme } from 'vitepress' +// @ts-expect-error -- Cannot change `module` option +import DefaultTheme from 'vitepress/theme' +// @ts-expect-error -- ignore +import Layout from './Layout.vue' +// @ts-expect-error -- ignore +import ESLintCodeBlock from './components/eslint-code-block.vue' +// @ts-expect-error -- ignore +import RulesTable from './components/rules-table.vue' + +const theme: Theme = { + ...DefaultTheme, + Layout, + enhanceApp(ctx) { + DefaultTheme.enhanceApp(ctx) + ctx.app.component('eslint-code-block', ESLintCodeBlock) + ctx.app.component('rules-table', RulesTable) + } +} +export default theme diff --git a/docs/.vitepress/vite-plugin.mts b/docs/.vitepress/vite-plugin.mts new file mode 100644 index 000000000..cd6811cb6 --- /dev/null +++ b/docs/.vitepress/vite-plugin.mts @@ -0,0 +1,83 @@ +import type { UserConfig } from 'vitepress' +import path from 'pathe' +import { fileURLToPath } from 'url' +import esbuild from 'esbuild' +type Plugin = Extract< + NonNullable['plugins']>[number], + { name: string } +> + +const libRoot = path.join(fileURLToPath(import.meta.url), '../../../lib') +export function vitePluginRequireResolve(): Plugin { + return { + name: 'vite-plugin-require.resolve', + transform(code, id, _options) { + if (id.startsWith(libRoot)) { + return code.replace(/require\.resolve/gu, '(function(){return 0})') + } + return undefined + } + } +} + +export function viteCommonjs(): Plugin { + return { + name: 'vite-plugin-cjs-to-esm', + apply: () => true, + async transform(code, id) { + if (!id.startsWith(libRoot)) { + return undefined + } + const base = transformRequire(code) + try { + const transformed = esbuild.transformSync(base, { + format: 'esm' + }) + return transformed.code + } catch (e) { + console.error('Transform error. base code:\n' + base, e) + } + return undefined + } + } +} + +/** + * Transform `require()` to `import` + */ +function transformRequire(code: string) { + if (!code.includes('require')) { + return code + } + const modules = new Map() + const replaced = code.replace( + /(\/\/[^\n\r]*|\/\*[\s\S]*?\*\/)|\brequire\s*\(\s*(["'].*?["'])\s*\)/gu, + (match, comment, moduleString) => { + if (comment) { + return match + } + + let id = + '__' + + moduleString.replace(/[^a-zA-Z0-9_$]+/gu, '_') + + Math.random().toString(32).substring(2) + while (code.includes(id) || modules.has(id)) { + id += Math.random().toString(32).substring(2) + } + modules.set(id, moduleString) + return id + '()' + } + ) + + return ( + [...modules] + .map(([id, moduleString]) => { + return `import * as __temp_${id} from ${moduleString}; +const ${id} = () => __temp_${id}.default || __temp_${id}; +` + }) + .join('') + + ';\n' + + replaced + ) +} diff --git a/docs/.vuepress/components/eslint-code-block.vue b/docs/.vuepress/components/eslint-code-block.vue deleted file mode 100644 index 391ae5490..000000000 --- a/docs/.vuepress/components/eslint-code-block.vue +++ /dev/null @@ -1,155 +0,0 @@ - - - - - diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js deleted file mode 100644 index d8b8b2928..000000000 --- a/docs/.vuepress/config.js +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @author Toru Nagashima - * See LICENSE file in root directory for full license. - */ -'use strict' - -const rules = require('../../tools/lib/rules') - -const uncategorizedRules = rules.filter( - (rule) => - !rule.meta.docs.categories && - !rule.meta.docs.extensionRule && - !rule.meta.deprecated -) -const uncategorizedExtensionRule = rules.filter( - (rule) => - !rule.meta.docs.categories && - rule.meta.docs.extensionRule && - !rule.meta.deprecated -) -const deprecatedRules = rules.filter((rule) => rule.meta.deprecated) - -const sidebarCategories = [ - { title: 'Base Rules', categoryIds: ['base'] }, - { - title: 'Priority A: Essential', - categoryIds: ['vue3-essential', 'essential'] - }, - { - title: 'Priority A: Essential for Vue.js 3.x', - categoryIds: ['vue3-essential'] - }, - { title: 'Priority A: Essential for Vue.js 2.x', categoryIds: ['essential'] }, - { - title: 'Priority B: Strongly Recommended', - categoryIds: ['vue3-strongly-recommended', 'strongly-recommended'] - }, - { - title: 'Priority B: Strongly Recommended for Vue.js 3.x', - categoryIds: ['vue3-strongly-recommended'] - }, - { - title: 'Priority B: Strongly Recommended for Vue.js 2.x', - categoryIds: ['strongly-recommended'] - }, - { - title: 'Priority C: Recommended', - categoryIds: ['vue3-recommended', 'recommended'] - }, - { - title: 'Priority C: Recommended for Vue.js 3.x', - categoryIds: ['vue3-recommended'] - }, - { - title: 'Priority C: Recommended for Vue.js 2.x', - categoryIds: ['recommended'] - } -] - -const categorizedRules = [] -for (const { title, categoryIds } of sidebarCategories) { - const categoryRules = rules - .filter((rule) => rule.meta.docs.categories && !rule.meta.deprecated) - .filter((rule) => - categoryIds.every((categoryId) => - rule.meta.docs.categories.includes(categoryId) - ) - ) - const children = categoryRules - .filter(({ ruleId }) => { - const exists = categorizedRules.some(({ children }) => - children.some(([, alreadyRuleId]) => alreadyRuleId === ruleId) - ) - return !exists - }) - .map(({ ruleId, name }) => [`/rules/${name}`, ruleId]) - - if (children.length === 0) { - continue - } - categorizedRules.push({ - title, - collapsable: false, - children - }) -} - -const extraCategories = [] -if (uncategorizedRules.length > 0) { - extraCategories.push({ - title: 'Uncategorized', - collapsable: false, - children: uncategorizedRules.map(({ ruleId, name }) => [ - `/rules/${name}`, - ruleId - ]) - }) -} -if (uncategorizedExtensionRule.length > 0) { - extraCategories.push({ - title: 'Extension Rules', - collapsable: false, - children: uncategorizedExtensionRule.map(({ ruleId, name }) => [ - `/rules/${name}`, - ruleId - ]) - }) -} -if (deprecatedRules.length > 0) { - extraCategories.push({ - title: 'Deprecated', - collapsable: false, - children: deprecatedRules.map(({ ruleId, name }) => [ - `/rules/${name}`, - ruleId - ]) - }) -} - -module.exports = { - configureWebpack(_config, _isServer) { - return { - resolve: { - alias: { - module: require.resolve('./shim/module') - } - } - } - }, - - base: '/', - title: 'eslint-plugin-vue', - description: 'Official ESLint plugin for Vue.js', - evergreen: true, - head: [['link', { rel: 'icon', href: '/favicon.png' }]], - - plugins: { - '@vuepress/pwa': { - serviceWorker: true, - updatePopup: true - } - }, - - themeConfig: { - repo: 'vuejs/eslint-plugin-vue', - docsRepo: 'vuejs/eslint-plugin-vue', - docsDir: 'docs', - docsBranch: 'master', - editLinks: true, - lastUpdated: true, - - nav: [ - { text: 'User Guide', link: '/user-guide/' }, - { text: 'Developer Guide', link: '/developer-guide/' }, - { text: 'Rules', link: '/rules/' }, - { text: 'Demo', link: 'https://mysticatea.github.io/vue-eslint-demo' } - ], - - sidebar: { - '/rules/': [ - '/rules/', - - // Rules in each category. - ...categorizedRules, - - // Rules in no category. - ...extraCategories - ], - - '/': ['/', '/user-guide/', '/developer-guide/', '/rules/'] - }, - - algolia: { - apiKey: 'b2b69365da747a9a9635cda391317c36', - indexName: 'eslint-plugin-vue' - } - } -} diff --git a/docs/.vuepress/shim/module.js b/docs/.vuepress/shim/module.js deleted file mode 100644 index 66ab9785e..000000000 --- a/docs/.vuepress/shim/module.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - createRequire: () => () => null -} diff --git a/docs/.vuepress/styles/index.styl b/docs/.vuepress/styles/index.styl deleted file mode 100644 index 48680bbf3..000000000 --- a/docs/.vuepress/styles/index.styl +++ /dev/null @@ -1,20 +0,0 @@ -.theme-container.rule-details .theme-default-content > h1 { - font-size: 1.8rem; - - + blockquote { - margin-top: -15px; - padding: 0; - border: 0; - font-weight: 500; - font-size: 1.4rem; - color: currentColor; - - ::first-letter { - text-transform: uppercase; - } - - p { - line-height: 1.2; - } - } -} diff --git a/docs/.vuepress/theme/index.js b/docs/.vuepress/theme/index.js deleted file mode 100644 index b91b8a576..000000000 --- a/docs/.vuepress/theme/index.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - extend: '@vuepress/theme-default' -} diff --git a/docs/.vuepress/theme/layouts/Layout.vue b/docs/.vuepress/theme/layouts/Layout.vue deleted file mode 100644 index 43b5ad685..000000000 --- a/docs/.vuepress/theme/layouts/Layout.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - - - diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 8bb745619..000000000 --- a/docs/README.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -sidebarDepth: 0 ---- - -# Introduction - -Official ESLint plugin for Vue.js. - -This plugin allows us to check the `