From 0a0e14cfa4f92605402cd82eacc8e8d7155b3c1f Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Thu, 21 Jul 2022 15:13:15 +0800 Subject: [PATCH] feat!: new implementation, adding a helper for alias, recommending `eslint-patch` Breaking change: 1. `eslint-plugin-*` are no longer peer dependencies. Instead, we recommend using `@rushstack/eslint-patch`, aligning with `@vue/eslint-config-typescript`. 2. No longer use a built-in webpack resolver. Instead, we provide a `createAliasSetting` helper to manually configure aliases for `eslint-plugin-import`. The reasoning was explained in previous commits. --- examples/create-vue-js/.eslintrc.cjs | 19 ++++ examples/create-vue-js/.gitignore | 28 ++++++ .../create-vue-js/.vscode/extensions.json | 3 + examples/create-vue-js/README.md | 35 +++++++ examples/create-vue-js/index.html | 13 +++ examples/create-vue-js/package.json | 25 +++++ examples/create-vue-js/public/favicon.ico | Bin 0 -> 4286 bytes examples/create-vue-js/src/App.vue | 85 +++++++++++++++++ examples/create-vue-js/src/assets/base.css | 74 +++++++++++++++ examples/create-vue-js/src/assets/logo.svg | 1 + examples/create-vue-js/src/assets/main.css | 35 +++++++ .../create-vue-js/src/components/FooComp.jsx | 7 ++ .../src/components/HelloWorld.vue | 43 +++++++++ .../create-vue-js/src/components/JsxInVue.vue | 9 ++ .../src/components/TheWelcome.vue | 84 +++++++++++++++++ .../src/components/WelcomeItem.vue | 86 ++++++++++++++++++ .../src/components/icons/IconCommunity.vue | 7 ++ .../components/icons/IconDocumentation.vue | 7 ++ .../src/components/icons/IconEcosystem.vue | 7 ++ .../src/components/icons/IconSupport.vue | 7 ++ .../src/components/icons/IconTooling.vue | 19 ++++ examples/create-vue-js/src/main.js | 15 +++ examples/create-vue-js/src/router/index.js | 23 +++++ examples/create-vue-js/src/stores/counter.js | 16 ++++ .../create-vue-js/src/views/AboutView.vue | 22 +++++ examples/create-vue-js/src/views/HomeView.vue | 9 ++ examples/create-vue-js/vite.config.js | 15 +++ examples/vue-cli-js/.browserslistrc | 4 + examples/vue-cli-js/.eslintrc.cjs | 19 ++++ examples/vue-cli-js/.gitignore | 23 +++++ examples/vue-cli-js/README.md | 24 +++++ examples/vue-cli-js/babel.config.js | 5 + examples/vue-cli-js/jsconfig.json | 19 ++++ examples/vue-cli-js/package.json | 26 ++++++ examples/vue-cli-js/public/favicon.ico | Bin 0 -> 4286 bytes examples/vue-cli-js/public/index.html | 17 ++++ examples/vue-cli-js/src/App.vue | 30 ++++++ examples/vue-cli-js/src/assets/logo.png | Bin 0 -> 6849 bytes .../vue-cli-js/src/components/HelloWorld.vue | 59 ++++++++++++ examples/vue-cli-js/src/main.js | 6 ++ examples/vue-cli-js/src/router/index.js | 25 +++++ examples/vue-cli-js/src/views/AboutView.vue | 5 + examples/vue-cli-js/src/views/HomeView.vue | 18 ++++ examples/vue-cli-js/vue.config.js | 4 + packages/eslint-config-standard/.eslintrc.cjs | 28 ++++++ packages/eslint-config-standard/README.md | 39 ++++++++ .../createAliasSetting.cjs | 25 +++++ packages/eslint-config-standard/index.cjs | 1 + packages/eslint-config-standard/index.js | 22 ----- packages/eslint-config-standard/package.json | 12 ++- 50 files changed, 1081 insertions(+), 24 deletions(-) create mode 100644 examples/create-vue-js/.eslintrc.cjs create mode 100644 examples/create-vue-js/.gitignore create mode 100644 examples/create-vue-js/.vscode/extensions.json create mode 100644 examples/create-vue-js/README.md create mode 100644 examples/create-vue-js/index.html create mode 100644 examples/create-vue-js/package.json create mode 100644 examples/create-vue-js/public/favicon.ico create mode 100644 examples/create-vue-js/src/App.vue create mode 100644 examples/create-vue-js/src/assets/base.css create mode 100644 examples/create-vue-js/src/assets/logo.svg create mode 100644 examples/create-vue-js/src/assets/main.css create mode 100644 examples/create-vue-js/src/components/FooComp.jsx create mode 100644 examples/create-vue-js/src/components/HelloWorld.vue create mode 100644 examples/create-vue-js/src/components/JsxInVue.vue create mode 100644 examples/create-vue-js/src/components/TheWelcome.vue create mode 100644 examples/create-vue-js/src/components/WelcomeItem.vue create mode 100644 examples/create-vue-js/src/components/icons/IconCommunity.vue create mode 100644 examples/create-vue-js/src/components/icons/IconDocumentation.vue create mode 100644 examples/create-vue-js/src/components/icons/IconEcosystem.vue create mode 100644 examples/create-vue-js/src/components/icons/IconSupport.vue create mode 100644 examples/create-vue-js/src/components/icons/IconTooling.vue create mode 100644 examples/create-vue-js/src/main.js create mode 100644 examples/create-vue-js/src/router/index.js create mode 100644 examples/create-vue-js/src/stores/counter.js create mode 100644 examples/create-vue-js/src/views/AboutView.vue create mode 100644 examples/create-vue-js/src/views/HomeView.vue create mode 100644 examples/create-vue-js/vite.config.js create mode 100644 examples/vue-cli-js/.browserslistrc create mode 100644 examples/vue-cli-js/.eslintrc.cjs create mode 100644 examples/vue-cli-js/.gitignore create mode 100644 examples/vue-cli-js/README.md create mode 100644 examples/vue-cli-js/babel.config.js create mode 100644 examples/vue-cli-js/jsconfig.json create mode 100644 examples/vue-cli-js/package.json create mode 100644 examples/vue-cli-js/public/favicon.ico create mode 100644 examples/vue-cli-js/public/index.html create mode 100644 examples/vue-cli-js/src/App.vue create mode 100644 examples/vue-cli-js/src/assets/logo.png create mode 100644 examples/vue-cli-js/src/components/HelloWorld.vue create mode 100644 examples/vue-cli-js/src/main.js create mode 100644 examples/vue-cli-js/src/router/index.js create mode 100644 examples/vue-cli-js/src/views/AboutView.vue create mode 100644 examples/vue-cli-js/src/views/HomeView.vue create mode 100644 examples/vue-cli-js/vue.config.js create mode 100644 packages/eslint-config-standard/.eslintrc.cjs create mode 100644 packages/eslint-config-standard/createAliasSetting.cjs create mode 100644 packages/eslint-config-standard/index.cjs delete mode 100644 packages/eslint-config-standard/index.js diff --git a/examples/create-vue-js/.eslintrc.cjs b/examples/create-vue-js/.eslintrc.cjs new file mode 100644 index 0000000..1be1485 --- /dev/null +++ b/examples/create-vue-js/.eslintrc.cjs @@ -0,0 +1,19 @@ +/* eslint-env node */ +require('@rushstack/eslint-patch/modern-module-resolution') + +const path = require('node:path') +const createAliasSetting = require('@vue/eslint-config-standard/createAliasSetting') + +module.exports = { + root: true, + extends: [ + 'plugin:vue/vue3-essential', + '@vue/eslint-config-standard' + ], + + settings: { + ...createAliasSetting({ + '@': `${path.resolve(__dirname, './src')}` + }) + } +} diff --git a/examples/create-vue-js/.gitignore b/examples/create-vue-js/.gitignore new file mode 100644 index 0000000..38adffa --- /dev/null +++ b/examples/create-vue-js/.gitignore @@ -0,0 +1,28 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +coverage +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/examples/create-vue-js/.vscode/extensions.json b/examples/create-vue-js/.vscode/extensions.json new file mode 100644 index 0000000..c0a6e5a --- /dev/null +++ b/examples/create-vue-js/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] +} diff --git a/examples/create-vue-js/README.md b/examples/create-vue-js/README.md new file mode 100644 index 0000000..4db78fa --- /dev/null +++ b/examples/create-vue-js/README.md @@ -0,0 +1,35 @@ +# . + +This template should help get you started developing with Vue 3 in Vite. + +## Recommended IDE Setup + +[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin). + +## Customize configuration + +See [Vite Configuration Reference](https://vitejs.dev/config/). + +## Project Setup + +```sh +npm install +``` + +### Compile and Hot-Reload for Development + +```sh +npm run dev +``` + +### Compile and Minify for Production + +```sh +npm run build +``` + +### Lint with [ESLint](https://eslint.org/) + +```sh +npm run lint +``` diff --git a/examples/create-vue-js/index.html b/examples/create-vue-js/index.html new file mode 100644 index 0000000..030a6ff --- /dev/null +++ b/examples/create-vue-js/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/examples/create-vue-js/package.json b/examples/create-vue-js/package.json new file mode 100644 index 0000000..358d731 --- /dev/null +++ b/examples/create-vue-js/package.json @@ -0,0 +1,25 @@ +{ + "name": "create-vue-js", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview --port 4173", + "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore" + }, + "dependencies": { + "pinia": "^2.0.16", + "vue": "^3.2.37", + "vue-router": "^4.1.2" + }, + "devDependencies": { + "@rushstack/eslint-patch": "^1.1.4", + "@vitejs/plugin-vue": "^3.0.1", + "@vitejs/plugin-vue-jsx": "^2.0.0", + "@vue/eslint-config-standard": "workspace:*", + "eslint": "^8.5.0", + "eslint-plugin-vue": "^9.0.0", + "vite": "^3.0.1", + "vue": "^3.2.37" + } +} diff --git a/examples/create-vue-js/public/favicon.ico b/examples/create-vue-js/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/examples/create-vue-js/src/App.vue b/examples/create-vue-js/src/App.vue new file mode 100644 index 0000000..e864195 --- /dev/null +++ b/examples/create-vue-js/src/App.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/examples/create-vue-js/src/assets/base.css b/examples/create-vue-js/src/assets/base.css new file mode 100644 index 0000000..71dc55a --- /dev/null +++ b/examples/create-vue-js/src/assets/base.css @@ -0,0 +1,74 @@ +/* color palette from */ +:root { + --vt-c-white: #ffffff; + --vt-c-white-soft: #f8f8f8; + --vt-c-white-mute: #f2f2f2; + + --vt-c-black: #181818; + --vt-c-black-soft: #222222; + --vt-c-black-mute: #282828; + + --vt-c-indigo: #2c3e50; + + --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); + --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); + --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); + + --vt-c-text-light-1: var(--vt-c-indigo); + --vt-c-text-light-2: rgba(60, 60, 60, 0.66); + --vt-c-text-dark-1: var(--vt-c-white); + --vt-c-text-dark-2: rgba(235, 235, 235, 0.64); +} + +/* semantic color variables for this project */ +:root { + --color-background: var(--vt-c-white); + --color-background-soft: var(--vt-c-white-soft); + --color-background-mute: var(--vt-c-white-mute); + + --color-border: var(--vt-c-divider-light-2); + --color-border-hover: var(--vt-c-divider-light-1); + + --color-heading: var(--vt-c-text-light-1); + --color-text: var(--vt-c-text-light-1); + + --section-gap: 160px; +} + +@media (prefers-color-scheme: dark) { + :root { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); + + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); + + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); + } +} + +*, +*::before, +*::after { + box-sizing: border-box; + margin: 0; + position: relative; + font-weight: normal; +} + +body { + min-height: 100vh; + color: var(--color-text); + background: var(--color-background); + transition: color 0.5s, background-color 0.5s; + line-height: 1.6; + font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, + Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-size: 15px; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} diff --git a/examples/create-vue-js/src/assets/logo.svg b/examples/create-vue-js/src/assets/logo.svg new file mode 100644 index 0000000..bc826fe --- /dev/null +++ b/examples/create-vue-js/src/assets/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/create-vue-js/src/assets/main.css b/examples/create-vue-js/src/assets/main.css new file mode 100644 index 0000000..c133f91 --- /dev/null +++ b/examples/create-vue-js/src/assets/main.css @@ -0,0 +1,35 @@ +@import "./base.css"; + +#app { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + + font-weight: normal; +} + +a, +.green { + text-decoration: none; + color: hsla(160, 100%, 37%, 1); + transition: 0.4s; +} + +@media (hover: hover) { + a:hover { + background-color: hsla(160, 100%, 37%, 0.2); + } +} + +@media (min-width: 1024px) { + body { + display: flex; + place-items: center; + } + + #app { + display: grid; + grid-template-columns: 1fr 1fr; + padding: 0 2rem; + } +} diff --git a/examples/create-vue-js/src/components/FooComp.jsx b/examples/create-vue-js/src/components/FooComp.jsx new file mode 100644 index 0000000..4e0c118 --- /dev/null +++ b/examples/create-vue-js/src/components/FooComp.jsx @@ -0,0 +1,7 @@ +import { defineComponent } from 'vue' + +export default defineComponent({ + setup () { + return () =>
Foo
+ } +}) diff --git a/examples/create-vue-js/src/components/HelloWorld.vue b/examples/create-vue-js/src/components/HelloWorld.vue new file mode 100644 index 0000000..1b8faac --- /dev/null +++ b/examples/create-vue-js/src/components/HelloWorld.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/examples/create-vue-js/src/components/JsxInVue.vue b/examples/create-vue-js/src/components/JsxInVue.vue new file mode 100644 index 0000000..71949cb --- /dev/null +++ b/examples/create-vue-js/src/components/JsxInVue.vue @@ -0,0 +1,9 @@ + diff --git a/examples/create-vue-js/src/components/TheWelcome.vue b/examples/create-vue-js/src/components/TheWelcome.vue new file mode 100644 index 0000000..d3d2e7a --- /dev/null +++ b/examples/create-vue-js/src/components/TheWelcome.vue @@ -0,0 +1,84 @@ + + + diff --git a/examples/create-vue-js/src/components/WelcomeItem.vue b/examples/create-vue-js/src/components/WelcomeItem.vue new file mode 100644 index 0000000..ba0def3 --- /dev/null +++ b/examples/create-vue-js/src/components/WelcomeItem.vue @@ -0,0 +1,86 @@ + + + diff --git a/examples/create-vue-js/src/components/icons/IconCommunity.vue b/examples/create-vue-js/src/components/icons/IconCommunity.vue new file mode 100644 index 0000000..2dc8b05 --- /dev/null +++ b/examples/create-vue-js/src/components/icons/IconCommunity.vue @@ -0,0 +1,7 @@ + diff --git a/examples/create-vue-js/src/components/icons/IconDocumentation.vue b/examples/create-vue-js/src/components/icons/IconDocumentation.vue new file mode 100644 index 0000000..6d4791c --- /dev/null +++ b/examples/create-vue-js/src/components/icons/IconDocumentation.vue @@ -0,0 +1,7 @@ + diff --git a/examples/create-vue-js/src/components/icons/IconEcosystem.vue b/examples/create-vue-js/src/components/icons/IconEcosystem.vue new file mode 100644 index 0000000..c3a4f07 --- /dev/null +++ b/examples/create-vue-js/src/components/icons/IconEcosystem.vue @@ -0,0 +1,7 @@ + diff --git a/examples/create-vue-js/src/components/icons/IconSupport.vue b/examples/create-vue-js/src/components/icons/IconSupport.vue new file mode 100644 index 0000000..7452834 --- /dev/null +++ b/examples/create-vue-js/src/components/icons/IconSupport.vue @@ -0,0 +1,7 @@ + diff --git a/examples/create-vue-js/src/components/icons/IconTooling.vue b/examples/create-vue-js/src/components/icons/IconTooling.vue new file mode 100644 index 0000000..660598d --- /dev/null +++ b/examples/create-vue-js/src/components/icons/IconTooling.vue @@ -0,0 +1,19 @@ + + diff --git a/examples/create-vue-js/src/main.js b/examples/create-vue-js/src/main.js new file mode 100644 index 0000000..8c0577f --- /dev/null +++ b/examples/create-vue-js/src/main.js @@ -0,0 +1,15 @@ +/* eslint import/no-unresolved: 2 */ +import { createApp } from 'vue' +import { createPinia } from 'pinia' + +import App from '@/App.vue' +import router from './router' + +import './assets/main.css' + +const app = createApp(App) + +app.use(createPinia()) +app.use(router) + +app.mount('#app') diff --git a/examples/create-vue-js/src/router/index.js b/examples/create-vue-js/src/router/index.js new file mode 100644 index 0000000..a49ae50 --- /dev/null +++ b/examples/create-vue-js/src/router/index.js @@ -0,0 +1,23 @@ +import { createRouter, createWebHistory } from 'vue-router' +import HomeView from '../views/HomeView.vue' + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes: [ + { + path: '/', + name: 'home', + component: HomeView + }, + { + path: '/about', + name: 'about', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/AboutView.vue') + } + ] +}) + +export default router diff --git a/examples/create-vue-js/src/stores/counter.js b/examples/create-vue-js/src/stores/counter.js new file mode 100644 index 0000000..6a4540e --- /dev/null +++ b/examples/create-vue-js/src/stores/counter.js @@ -0,0 +1,16 @@ +import { defineStore } from 'pinia' + +export const useCounterStore = defineStore({ + id: 'counter', + state: () => ({ + counter: 0 + }), + getters: { + doubleCount: (state) => state.counter * 2 + }, + actions: { + increment () { + this.counter++ + } + } +}) diff --git a/examples/create-vue-js/src/views/AboutView.vue b/examples/create-vue-js/src/views/AboutView.vue new file mode 100644 index 0000000..56a4a7f --- /dev/null +++ b/examples/create-vue-js/src/views/AboutView.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/examples/create-vue-js/src/views/HomeView.vue b/examples/create-vue-js/src/views/HomeView.vue new file mode 100644 index 0000000..225d93a --- /dev/null +++ b/examples/create-vue-js/src/views/HomeView.vue @@ -0,0 +1,9 @@ + + + diff --git a/examples/create-vue-js/vite.config.js b/examples/create-vue-js/vite.config.js new file mode 100644 index 0000000..2fb21e9 --- /dev/null +++ b/examples/create-vue-js/vite.config.js @@ -0,0 +1,15 @@ +import { fileURLToPath, URL } from 'node:url' + +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)) + } + } +}) diff --git a/examples/vue-cli-js/.browserslistrc b/examples/vue-cli-js/.browserslistrc new file mode 100644 index 0000000..dc3bc09 --- /dev/null +++ b/examples/vue-cli-js/.browserslistrc @@ -0,0 +1,4 @@ +> 1% +last 2 versions +not dead +not ie 11 diff --git a/examples/vue-cli-js/.eslintrc.cjs b/examples/vue-cli-js/.eslintrc.cjs new file mode 100644 index 0000000..1be1485 --- /dev/null +++ b/examples/vue-cli-js/.eslintrc.cjs @@ -0,0 +1,19 @@ +/* eslint-env node */ +require('@rushstack/eslint-patch/modern-module-resolution') + +const path = require('node:path') +const createAliasSetting = require('@vue/eslint-config-standard/createAliasSetting') + +module.exports = { + root: true, + extends: [ + 'plugin:vue/vue3-essential', + '@vue/eslint-config-standard' + ], + + settings: { + ...createAliasSetting({ + '@': `${path.resolve(__dirname, './src')}` + }) + } +} diff --git a/examples/vue-cli-js/.gitignore b/examples/vue-cli-js/.gitignore new file mode 100644 index 0000000..403adbc --- /dev/null +++ b/examples/vue-cli-js/.gitignore @@ -0,0 +1,23 @@ +.DS_Store +node_modules +/dist + + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/examples/vue-cli-js/README.md b/examples/vue-cli-js/README.md new file mode 100644 index 0000000..76dd000 --- /dev/null +++ b/examples/vue-cli-js/README.md @@ -0,0 +1,24 @@ +# vue-cli-js + +## Project setup +``` +yarn install +``` + +### Compiles and hot-reloads for development +``` +yarn serve +``` + +### Compiles and minifies for production +``` +yarn build +``` + +### Lints and fixes files +``` +yarn lint +``` + +### Customize configuration +See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/examples/vue-cli-js/babel.config.js b/examples/vue-cli-js/babel.config.js new file mode 100644 index 0000000..e955840 --- /dev/null +++ b/examples/vue-cli-js/babel.config.js @@ -0,0 +1,5 @@ +module.exports = { + presets: [ + '@vue/cli-plugin-babel/preset' + ] +} diff --git a/examples/vue-cli-js/jsconfig.json b/examples/vue-cli-js/jsconfig.json new file mode 100644 index 0000000..4aafc5f --- /dev/null +++ b/examples/vue-cli-js/jsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "esnext", + "baseUrl": "./", + "moduleResolution": "node", + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": [ + "esnext", + "dom", + "dom.iterable", + "scripthost" + ] + } +} diff --git a/examples/vue-cli-js/package.json b/examples/vue-cli-js/package.json new file mode 100644 index 0000000..65550ec --- /dev/null +++ b/examples/vue-cli-js/package.json @@ -0,0 +1,26 @@ +{ + "name": "vue-cli-js", + "version": "0.1.0", + "private": true, + "scripts": { + "serve": "vue-cli-service serve", + "build": "vue-cli-service build", + "lint": "vue-cli-service lint" + }, + "dependencies": { + "core-js": "^3.8.3", + "vue": "^3.2.13", + "vue-router": "^4.0.3" + }, + "devDependencies": { + "@babel/core": "^7.12.16", + "@rushstack/eslint-patch": "^1.1.4", + "@vue/cli-plugin-babel": "~5.0.0", + "@vue/cli-plugin-eslint": "~5.0.0", + "@vue/cli-plugin-router": "~5.0.0", + "@vue/cli-service": "~5.0.0", + "@vue/eslint-config-standard": "workspace:*", + "eslint": "^8.5.0", + "eslint-plugin-vue": "^9.0.0" + } +} diff --git a/examples/vue-cli-js/public/favicon.ico b/examples/vue-cli-js/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2 GIT binary patch literal 4286 zcmds*O-Phc6o&64GDVCEQHxsW(p4>LW*W<827=Unuo8sGpRux(DN@jWP-e29Wl%wj zY84_aq9}^Am9-cWTD5GGEo#+5Fi2wX_P*bo+xO!)p*7B;iKlbFd(U~_d(U?#hLj56 zPhFkj-|A6~Qk#@g^#D^U0XT1cu=c-vu1+SElX9NR;kzAUV(q0|dl0|%h|dI$%VICy zJnu2^L*Te9JrJMGh%-P79CL0}dq92RGU6gI{v2~|)p}sG5x0U*z<8U;Ij*hB9z?ei z@g6Xq-pDoPl=MANPiR7%172VA%r)kevtV-_5H*QJKFmd;8yA$98zCxBZYXTNZ#QFk2(TX0;Y2dt&WitL#$96|gJY=3xX zpCoi|YNzgO3R`f@IiEeSmKrPSf#h#Qd<$%Ej^RIeeYfsxhPMOG`S`Pz8q``=511zm zAm)MX5AV^5xIWPyEu7u>qYs?pn$I4nL9J!=K=SGlKLXpE<5x+2cDTXq?brj?n6sp= zphe9;_JHf40^9~}9i08r{XM$7HB!`{Ys~TK0kx<}ZQng`UPvH*11|q7&l9?@FQz;8 zx!=3<4seY*%=OlbCbcae?5^V_}*K>Uo6ZWV8mTyE^B=DKy7-sdLYkR5Z?paTgK-zyIkKjIcpyO z{+uIt&YSa_$QnN_@t~L014dyK(fOOo+W*MIxbA6Ndgr=Y!f#Tokqv}n<7-9qfHkc3 z=>a|HWqcX8fzQCT=dqVbogRq!-S>H%yA{1w#2Pn;=e>JiEj7Hl;zdt-2f+j2%DeVD zsW0Ab)ZK@0cIW%W7z}H{&~yGhn~D;aiP4=;m-HCo`BEI+Kd6 z={Xwx{TKxD#iCLfl2vQGDitKtN>z|-AdCN|$jTFDg0m3O`WLD4_s#$S literal 0 HcmV?d00001 diff --git a/examples/vue-cli-js/public/index.html b/examples/vue-cli-js/public/index.html new file mode 100644 index 0000000..3e5a139 --- /dev/null +++ b/examples/vue-cli-js/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + <%= htmlWebpackPlugin.options.title %> + + + +
+ + + diff --git a/examples/vue-cli-js/src/App.vue b/examples/vue-cli-js/src/App.vue new file mode 100644 index 0000000..a753dba --- /dev/null +++ b/examples/vue-cli-js/src/App.vue @@ -0,0 +1,30 @@ + + + diff --git a/examples/vue-cli-js/src/assets/logo.png b/examples/vue-cli-js/src/assets/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..f3d2503fc2a44b5053b0837ebea6e87a2d339a43 GIT binary patch literal 6849 zcmaKRcUV(fvo}bjDT-7nLI_nlK}sT_69H+`qzVWDA|yaU?}j417wLi^B1KB1SLsC& zL0ag7$U(XW5YR7p&Ux?sP$d4lvMt8C^+TcQu4F zQqv!UF!I+kw)c0jhd6+g6oCr9P?7)?!qX1ui*iL{p}sKCAGuJ{{W)0z1pLF|=>h}& zt(2Lr0Z`2ig8<5i%Zk}cO5Fm=LByqGWaS`oqChZdEFmc`0hSb#gg|Aap^{+WKOYcj zHjINK)KDG%&s?Mt4CL(T=?;~U@bU2x_mLKN!#GJuK_CzbNw5SMEJorG!}_5;?R>@1 zSl)jns3WlU7^J%=(hUtfmuUCU&C3%8B5C^f5>W2Cy8jW3#{Od{lF1}|?c61##3dzA zsPlFG;l_FzBK}8>|H_Ru_H#!_7$UH4UKo3lKOA}g1(R&|e@}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rRC8Y%yxkH;d!MdY+Tw@r zjpSnK`;C-U{ATcgaxoEpP0Gf+tx);buOMlK=01D|J+ROu37qc*rD(w`#O=3*O*w9?biwNoq3WN1`&Wp8TvKj3C z3HR9ssH7a&Vr<6waJrU zdLg!ieYz%U^bmpn%;(V%%ugMk92&?_XX1K@mwnVSE6!&%P%Wdi7_h`CpScvspMx?N zQUR>oadnG17#hNc$pkTp+9lW+MBKHRZ~74XWUryd)4yd zj98$%XmIL4(9OnoeO5Fnyn&fpQ9b0h4e6EHHw*l68j;>(ya`g^S&y2{O8U>1*>4zR zq*WSI_2o$CHQ?x0!wl9bpx|Cm2+kFMR)oMud1%n2=qn5nE&t@Fgr#=Zv2?}wtEz^T z9rrj=?IH*qI5{G@Rn&}^Z{+TW}mQeb9=8b<_a`&Cm#n%n~ zU47MvCBsdXFB1+adOO)03+nczfWa#vwk#r{o{dF)QWya9v2nv43Zp3%Ps}($lA02*_g25t;|T{A5snSY?3A zrRQ~(Ygh_ebltHo1VCbJb*eOAr;4cnlXLvI>*$-#AVsGg6B1r7@;g^L zFlJ_th0vxO7;-opU@WAFe;<}?!2q?RBrFK5U{*ai@NLKZ^};Ul}beukveh?TQn;$%9=R+DX07m82gP$=}Uo_%&ngV`}Hyv8g{u z3SWzTGV|cwQuFIs7ZDOqO_fGf8Q`8MwL}eUp>q?4eqCmOTcwQuXtQckPy|4F1on8l zP*h>d+cH#XQf|+6c|S{7SF(Lg>bR~l(0uY?O{OEVlaxa5@e%T&xju=o1`=OD#qc16 zSvyH*my(dcp6~VqR;o(#@m44Lug@~_qw+HA=mS#Z^4reBy8iV?H~I;{LQWk3aKK8$bLRyt$g?- +
+

{{ msg }}

+

+ For a guide and recipes on how to configure / customize this project,
+ check out the + vue-cli documentation. +

+

Installed CLI Plugins

+ +

Essential Links

+ +

Ecosystem

+ +
+ + + + + + diff --git a/examples/vue-cli-js/src/main.js b/examples/vue-cli-js/src/main.js new file mode 100644 index 0000000..df199b1 --- /dev/null +++ b/examples/vue-cli-js/src/main.js @@ -0,0 +1,6 @@ +/* eslint import/no-unresolved: 2 */ +import { createApp } from 'vue' +import App from '@/App.vue' +import router from './router' + +createApp(App).use(router).mount('#app') diff --git a/examples/vue-cli-js/src/router/index.js b/examples/vue-cli-js/src/router/index.js new file mode 100644 index 0000000..d3a856e --- /dev/null +++ b/examples/vue-cli-js/src/router/index.js @@ -0,0 +1,25 @@ +import { createRouter, createWebHistory } from 'vue-router' +import HomeView from '../views/HomeView.vue' + +const routes = [ + { + path: '/', + name: 'home', + component: HomeView + }, + { + path: '/about', + name: 'about', + // route level code-splitting + // this generates a separate chunk (about.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue') + } +] + +const router = createRouter({ + history: createWebHistory(process.env.BASE_URL), + routes +}) + +export default router diff --git a/examples/vue-cli-js/src/views/AboutView.vue b/examples/vue-cli-js/src/views/AboutView.vue new file mode 100644 index 0000000..3fa2807 --- /dev/null +++ b/examples/vue-cli-js/src/views/AboutView.vue @@ -0,0 +1,5 @@ + diff --git a/examples/vue-cli-js/src/views/HomeView.vue b/examples/vue-cli-js/src/views/HomeView.vue new file mode 100644 index 0000000..e8d96d7 --- /dev/null +++ b/examples/vue-cli-js/src/views/HomeView.vue @@ -0,0 +1,18 @@ + + + diff --git a/examples/vue-cli-js/vue.config.js b/examples/vue-cli-js/vue.config.js new file mode 100644 index 0000000..910e297 --- /dev/null +++ b/examples/vue-cli-js/vue.config.js @@ -0,0 +1,4 @@ +const { defineConfig } = require('@vue/cli-service') +module.exports = defineConfig({ + transpileDependencies: true +}) diff --git a/packages/eslint-config-standard/.eslintrc.cjs b/packages/eslint-config-standard/.eslintrc.cjs new file mode 100644 index 0000000..72efea8 --- /dev/null +++ b/packages/eslint-config-standard/.eslintrc.cjs @@ -0,0 +1,28 @@ +const { DEFAULT_RESOLVER_SETTING } = require('./createAliasSetting.cjs') + +module.exports = { + extends: [ + require.resolve('eslint-config-standard') + ], + settings: { + 'import/resolver': DEFAULT_RESOLVER_SETTING, + + // A list of file extensions that will be parsed as modules and inspected for exports. + // Not actually needed, as none of the `import/*` rules that `standard` used requires this setting. + // Added for easier customization. + 'import/extensions': [ + '.mjs', + '.js', + '.jsx' + ] + }, + rules: { + // Cannot omit `.vue` extensions. + // This should be enforced all across the Vue.js ecosystem. + 'import/extensions': [ + 'error', { + vue: 'always' + } + ] + } +} diff --git a/packages/eslint-config-standard/README.md b/packages/eslint-config-standard/README.md index e69de29..4b2dd58 100644 --- a/packages/eslint-config-standard/README.md +++ b/packages/eslint-config-standard/README.md @@ -0,0 +1,39 @@ +# `@vue/eslint-config-standard` + +> eslint-config-standard for Vue + +This config is specifically designed to be used by `@vue/cli` & `create-vue` setups +and is not meant for outside use (it can be used but some adaptations +on the user side might be needed - for details see the config file). + +A part of its design is that this config may implicitly depend on +other parts of `@vue/cli`/`create-vue` setups, such as `eslint-plugin-vue` being +extended in the same resulting config. + +## Installation + +In order to work around [a known limitation in ESLint](https://github.com/eslint/eslint/issues/3458), we recommend you to use this package alongside `@rushstack/eslint-patch`, so that you don't have to install too many dependencies: + +```sh +npm add --dev @vue/eslint-config-standard @rushstack/eslint-patch +``` + +## Usage + +An example `.eslintrc.cjs`: + +```js +/* eslint-env node */ +require("@rushstack/eslint-patch/modern-module-resolution") + +module.exports = { + extends: [ + 'plugin:vue/vue3-essential', + '@vue/eslint-config-standard' + ] +} +``` + +## Aliases + +As diff --git a/packages/eslint-config-standard/createAliasSetting.cjs b/packages/eslint-config-standard/createAliasSetting.cjs new file mode 100644 index 0000000..77d147c --- /dev/null +++ b/packages/eslint-config-standard/createAliasSetting.cjs @@ -0,0 +1,25 @@ +const DEFAULT_RESOLVER_SETTING = { + // https://github.com/benmosher/eslint-plugin-import/issues/1396 + // The default config is good enough, so just an empty object here + [require.resolve('eslint-import-resolver-node')]: {} +} + +/** + * create an ESLint `settings` object + * that help configure the import resolver with given aliases. + * @param {Object} alias a key-value pair, key is the alias prefix, value is the actual path. Note it's not glob or regex. + * @returns an object to be spread into `settings` property of ESLint config. + */ +module.exports = function createAliasSetting (alias) { + return { + 'import/resolver': { + ...DEFAULT_RESOLVER_SETTING, + [require.resolve('eslint-import-resolver-custom-alias')]: { + alias, + extensions: ['.mjs', '.js', '.jsx', '.json', '.node'] + } + } + } +} + +module.exports.DEFAULT_RESOLVER_SETTING = DEFAULT_RESOLVER_SETTING diff --git a/packages/eslint-config-standard/index.cjs b/packages/eslint-config-standard/index.cjs new file mode 100644 index 0000000..75dc27c --- /dev/null +++ b/packages/eslint-config-standard/index.cjs @@ -0,0 +1 @@ +module.exports = require('./.eslintrc.cjs') diff --git a/packages/eslint-config-standard/index.js b/packages/eslint-config-standard/index.js deleted file mode 100644 index ba6a110..0000000 --- a/packages/eslint-config-standard/index.js +++ /dev/null @@ -1,22 +0,0 @@ -// https://github.com/benmosher/eslint-plugin-import/issues/1396 -const resolver = { - [require.resolve('eslint-import-resolver-node')]: {}, -} - -// TODO: API for custom aliases - -module.exports = { - extends: [ - require.resolve('eslint-config-standard') - ], - settings: { - 'import/resolver': resolver, - 'import/extensions': [ - '.js', - '.jsx', - '.mjs', - '.ts', - '.tsx', - ], - }, -} diff --git a/packages/eslint-config-standard/package.json b/packages/eslint-config-standard/package.json index 39bb384..016146e 100644 --- a/packages/eslint-config-standard/package.json +++ b/packages/eslint-config-standard/package.json @@ -2,7 +2,12 @@ "name": "@vue/eslint-config-standard", "version": "7.0.0", "description": "eslint-config-standard for Vue.js projects", - "main": "index.js", + "main": "index.cjs", + "exports": { + ".": "./index.cjs", + "./createAliasSetting": "./createAliasSetting.cjs", + "./package.json": "./package.json" + }, "publishConfig": { "access": "public" }, @@ -29,9 +34,12 @@ "eslint-plugin-import": "^2.25.2", "eslint-plugin-n": "^15.0.0", "eslint-plugin-promise": "^6.0.0", - "eslint-plugin-vue": "^8.7.1" + "eslint-plugin-vue": "^9.2.0" }, "peerDependencies": { "eslint": "^8.0.1" + }, + "devDependencies": { + "eslint": "^8.0.1" } }