Skip to content

Commit 63b8aee

Browse files
committed
Adds eslint and prettier
1 parent f8a1d1b commit 63b8aee

16 files changed

+989
-210
lines changed

.eslintrc.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
es2021: true,
6+
node: true,
7+
},
8+
parserOptions: {
9+
ecmaVersion: 2021,
10+
},
11+
extends: [
12+
'plugin:vue/vue3-recommended',
13+
'eslint:recommended',
14+
'@vue/typescript/recommended',
15+
'@vue/prettier',
16+
'@vue/prettier/@typescript-eslint',
17+
'plugin:prettier/recommended',
18+
],
19+
rules: {
20+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
21+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
22+
'@typescript-eslint/interface-name-prefix': 'off',
23+
'@typescript-eslint/explicit-function-return-type': 'off',
24+
'@typescript-eslint/explicit-module-boundary-types': 'off',
25+
'@typescript-eslint/no-explicit-any': 'off',
26+
'@typescript-eslint/no-non-null-assertion': 'off',
27+
'@typescript-eslint/no-unused-vars': ['off', { argsIgnorePattern: '^_' }],
28+
'vue/script-setup-uses-vars': 'error',
29+
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
30+
},
31+
}

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
src/dist
2+
demo/dist
3+
node_modules

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"tabWidth": 2,
3+
"semi": false,
4+
"singleQuote": true,
5+
"quoteProps": "as-needed",
6+
"trailingComma": "es5",
7+
"bracketSpacing": true,
8+
"arrowParens": "avoid",
9+
"printWidth": 120,
10+
"vueIndentScriptAndStyle": false
11+
}

demo/sandbox/src/Sandbox.vue

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,38 @@
11
<template>
22
<div>
3-
<input
4-
type="text"
5-
class="input"
6-
placeholder="Watch me change size with my content!"
7-
v-model="msg"
8-
v-autowidth
9-
/>
3+
<input v-model="msg" v-autowidth type="text" class="input" placeholder="Watch me change size with my content!" />
104
</div>
115

126
<div>
13-
<input
14-
type="text"
15-
class="input"
16-
v-model="msg"
17-
v-autowidth="{ minWidth: '75px', maxWidth: '100px' }"
18-
/>
7+
<input v-model="msg" v-autowidth="{ minWidth: '75px', maxWidth: '100px' }" type="text" class="input" />
198
</div>
209

2110
<div>
2211
<input
12+
v-model="msg"
13+
v-autowidth="{ comfortZone: '10px' }"
2314
type="text"
2415
class="input"
25-
v-model="msg"
2616
placeholder="Watch me change size with my content!"
27-
v-autowidth="{ comfortZone: '10px' }"
2817
/>
2918
</div>
3019

3120
<div>
32-
<input
33-
type="text"
34-
class="input"
35-
placeholder="Watch me change size with my content!"
36-
v-autowidth
37-
/>
21+
<input v-autowidth type="text" class="input" placeholder="Watch me change size with my content!" />
3822
</div>
3923
</template>
4024
<script lang="ts">
41-
import { defineComponent, ref } from "vue";
25+
import { defineComponent, ref } from 'vue'
4226
4327
export default defineComponent({
4428
setup() {
45-
const msg = ref("");
29+
const msg = ref('')
4630
return {
4731
ref,
4832
msg,
49-
};
33+
}
5034
},
51-
});
35+
})
5236
</script>
5337

5438
<style>

demo/sandbox/src/main.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { createApp } from "vue";
2-
import Sandbox from "./Sandbox.vue";
3-
import { plugin as VueInputAutowidth } from "../../../src/";
4-
import "../../src/app.css";
1+
import { createApp } from 'vue'
2+
import Sandbox from './Sandbox.vue'
3+
import { plugin as VueInputAutowidth } from '../../../src/'
4+
import '../../src/app.css'
55

6-
createApp(Sandbox).use(VueInputAutowidth).mount("#app");
6+
createApp(Sandbox).use(VueInputAutowidth).mount('#app')

demo/src/App.vue

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<template>
22
<div class="px-8 my-32 md:px-0">
3-
<div
4-
class="flex items-center justify-between w-full mx-auto mt-8 max-w-prose"
5-
>
3+
<div class="flex items-center justify-between w-full mx-auto mt-8 max-w-prose">
64
<h1 class="text-4xl font-bold">
75
<span class="relative inline-block top-1">↔️</span>
86
<span class="inline-block ml-2">vue-input-autowidth</span>
@@ -33,13 +31,7 @@
3331
</nav>
3432
</div>
3533
<div class="w-full mx-auto mt-8 max-w-prose">
36-
<input
37-
type="text"
38-
class="input"
39-
placeholder="Watch me change size with my content!"
40-
v-model="msg"
41-
v-autowidth
42-
/>
34+
<input v-model="msg" v-autowidth type="text" class="input" placeholder="Watch me change size with my content!" />
4335
</div>
4436
<div class="w-full mx-auto mt-8 prose max-w-prose">
4537
<h2>Install</h2>
@@ -57,56 +49,54 @@
5749
<p>You can pass various options to the directive</p>
5850
<highlightjs language="xml" :code="showOptionsCode" />
5951
<input
60-
type="text"
61-
class="input"
62-
placeholder="An example with custom options"
6352
v-model="msg"
6453
v-autowidth="{
6554
minWidth: '75px',
6655
maxWidth: '75%',
6756
comfortZone: '1ch',
6857
}"
58+
type="text"
59+
class="input"
60+
placeholder="An example with custom options"
6961
/>
7062

7163
<footer>
72-
<p class="text-gray-500">
73-
&copy; {{ new Date().getFullYear() }} Collin Henderson
74-
</p>
64+
<p class="text-gray-500">&copy; {{ new Date().getFullYear() }} Collin Henderson</p>
7565
</footer>
7666
</div>
7767
</div>
7868
</template>
7969

8070
<script>
81-
import { ref } from "vue";
71+
import { defineComponent, ref } from 'vue'
8272
8373
export default defineComponent({
8474
setup() {
85-
const msg = ref("");
75+
const msg = ref('')
8676
8777
const installCode = ref(`$ npm install vue-input-autowidth@next --save
8878
# or...
89-
$ yarn add vue-input-autowidth@next`);
79+
$ yarn add vue-input-autowidth@next`)
9080
const addGlobalCode = ref(`import { createApp } from 'vue'
9181
import App from './App.vue'
9282
import { plugin as VueInputAutowidth } from 'vue-input-autowidth'
9383
9484
createApp(App).use(VueInputAutowidth).mount("#app")
95-
`);
85+
`)
9686
const perComponentCode = `import { directive as VueInputAutowidth } from 'vue-input-autowidth'
9787
9888
export default {
9989
directives: { autowidth: VueInputAutowidth },
10090
setup() {
10191
...
10292
},
103-
}`;
93+
}`
10494
const useDirectiveCode = `<input
10595
type="text"
10696
placeholder="Watch me change size with my content!"
10797
v-model="msg"
10898
v-autowidth
109-
/>`;
99+
/>`
110100
111101
const showOptionsCode = ref(`<input
112102
type="text"
@@ -117,17 +107,17 @@ export default {
117107
maxWidth: '75%',
118108
comfortZone: '1ch',
119109
}"
120-
/>`);
110+
/>`)
121111
return {
122112
msg,
123113
installCode,
124114
addGlobalCode,
125115
perComponentCode,
126116
useDirectiveCode,
127117
showOptionsCode,
128-
};
118+
}
129119
},
130-
});
120+
})
131121
</script>
132122

133123
<style>

demo/src/main.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { createApp } from "vue";
2-
import App from "./App.vue";
3-
import { plugin as VueInputAutowidth } from "../../src/";
4-
import "highlight.js/lib/common";
5-
import hljsVuePlugin from "@highlightjs/vue-plugin";
6-
import "highlight.js/styles/atom-one-dark.css";
7-
import "./app.css";
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
import { plugin as VueInputAutowidth } from '../../src/'
4+
import 'highlight.js/lib/common'
5+
import hljsVuePlugin from '@highlightjs/vue-plugin'
6+
import 'highlight.js/styles/atom-one-dark.css'
7+
import './app.css'
88

9-
createApp(App).use(VueInputAutowidth).use(hljsVuePlugin).mount("#app");
9+
createApp(App).use(VueInputAutowidth).use(hljsVuePlugin).mount('#app')

demo/tailwind.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module.exports = {
2-
mode: "jit",
3-
purge: ["./index.html", "./src/**/*.{vue,js,ts}"],
2+
mode: 'jit',
3+
purge: ['./index.html', './src/**/*.{vue,js,ts}'],
44
darkMode: false, // or 'media' or 'class'
55
theme: {
66
extend: {},
77
},
88
variants: {
99
extend: {},
1010
},
11-
plugins: [require("@tailwindcss/typography")],
12-
};
11+
plugins: [require('@tailwindcss/typography')],
12+
}

demo/tsconfig.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,5 @@
1414
"allowJs": true,
1515
"types": ["node", "vite/client"]
1616
},
17-
"include": [
18-
"src/**/*.ts",
19-
"src/**/*.d.ts",
20-
"src/**/*.vue",
21-
"vite.config.ts",
22-
"sandbox/**/*.ts",
23-
"sandbox/**/*.d.ts"
24-
]
17+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue", "vite.config.ts", "sandbox/**/*.ts", "sandbox/**/*.d.ts"]
2518
}

demo/vite.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { defineConfig } from "vite";
2-
import vue from "@vitejs/plugin-vue";
1+
import { defineConfig } from 'vite'
2+
import vue from '@vitejs/plugin-vue'
33

44
// https://vitejs.dev/config/
55
export default defineConfig({
66
plugins: [vue()],
77
server: {
88
port: 3001,
99
},
10-
});
10+
})

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,24 @@
2020
"serve": "vite preview",
2121
"test": "start-server-and-test demo http-get://localhost:3001 cypress",
2222
"cypress": "cypress run",
23+
"lint": "eslint --ext .ts,vue --ignore-path .gitignore ./src ./demo ./tests",
24+
"format": "prettier ./src ./demo ./tests -w -u",
2325
"demo": "cd demo && vite",
2426
"demo:build": "cd demo && vite build",
2527
"postinstall": "cd demo && yarn"
2628
},
2729
"devDependencies": {
2830
"@types/jest": "^27.0.1",
2931
"@types/node": "^16.9.2",
32+
"@typescript-eslint/eslint-plugin": "^4.31.2",
33+
"@typescript-eslint/parser": "^4.31.2",
34+
"@vue/eslint-config-prettier": "^6.0.0",
35+
"@vue/eslint-config-typescript": "^7.0.0",
3036
"cypress": "^8.4.1",
37+
"eslint": "^7.32.0",
38+
"eslint-plugin-prettier": "^4.0.0",
39+
"eslint-plugin-vue": "^7.18.0",
40+
"prettier": "2.4.1",
3141
"start-server-and-test": "^1.14.0",
3242
"typescript": "^4.3.2",
3343
"vite": "^2.5.4",

0 commit comments

Comments
 (0)