Merge pull request #130 from webgems/features/prettier

Add ESLint and prettier
This commit is contained in:
wellá
2019-10-02 10:37:41 +02:00
committed by GitHub
15 changed files with 900 additions and 66 deletions

30
.eslintrc.js Normal file
View File

@@ -0,0 +1,30 @@
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint'
},
extends: [
'eslint:recommended',
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/recommended',
// 'plugin:prettier/recommended'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
'semi': ['error', 'never'],
'no-console': 'off',
'vue/max-attributes-per-line': 'off',
'quotes': ['error', 'single', { 'avoidEscape': true }],
'comma-dangle': ['error', 'always-multiline'],
'vue/require-default-prop': 'off',
}
}

View File

@@ -10,7 +10,11 @@
<script> <script>
export default { export default {
props: ['resource', 'isActive', 'createCopyUrl'], props: {
resource: Object,
isActive: Boolean,
createCopyUrl: Function,
},
} }
</script> </script>

View File

@@ -7,10 +7,10 @@
<script> <script>
export default { export default {
methods: { methods: {
goToHome(){ goToHome() {
this.$router.push("/") this.$router.push('/')
} },
} },
} }
</script> </script>
@@ -26,16 +26,14 @@ export default {
cursor: pointer; cursor: pointer;
} }
.gem { .gem {
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwc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RkYiIHBvaW50cz0iMTUsMTcgNSwxNyAyMy45OTYsNDIuMTQ5ICIvPjxwb2x5Z29uIGZpbGw9IiMwMEU1RkYiIHBvaW50cz0iMTUsMTcgMjQsMTUgMzMsMTcgMjQsMTkgIi8+PC9nPjxwb2x5Z29uIGZpbGw9IiNFMEY3RkEiIHBvaW50cz0iNSwxNyAxMCwxNSAxNSwxNyAxMCwxOSAiLz48L3N2Zz4=);
background-size: cover; background-size: cover;
width:35px; width: 35px;
height:35px; height: 35px;
} }
p { p {
margin: 0 0 0 .3rem; margin: 0 0 0 0.3rem;
font-size: 14px; font-size: 14px;
} }
} }
</style> </style>

View File

@@ -10,28 +10,28 @@
</template> </template>
<script> <script>
import { mapMutations } from "vuex"; import { mapMutations } from 'vuex'
export default { export default {
data() { data() {
return { return {
categories: [{ slug: "", title: "" }] categories: [{ slug: '', title: '' }],
}; }
}, },
computed: { computed: {
areCardsVisible() { areCardsVisible() {
return this.$store.getters['Sidebar/areCardsVisible'] return this.$store.getters['Sidebar/areCardsVisible']
} },
}, },
created() { created() {
this.categories = this.$store.getters['data/resources'].map(({ title, slug }) => ({ title, slug })) this.categories = this.$store.getters['data/resources'].map(({ title, slug }) => ({ title, slug }))
}, },
methods: { methods: {
...mapMutations({ ...mapMutations({
toggleCardsVisible: "Sidebar/toggleCardsVisible" toggleCardsVisible: 'Sidebar/toggleCardsVisible',
}) }),
} },
}; }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -5,15 +5,19 @@
td.tableRow--links td.tableRow--links
tr tr
td td
a.tableRow--reference(@click='createCopyUrl(resource)') Copy a.tableRow--reference(@click="createCopyUrl(resource)") Copy
td td
a.tableRow--target(:href="resource.url" :target='resource.title' rel='noreferrer') Open a.tableRow--target(:href="resource.url" :target='resource.title' rel='noreferrer') Open
</template> </template>
<script> <script>
export default { export default {
props: ['resource', 'isActive', 'createCopyUrl'], props: {
}; resource: Object,
isActive: Boolean,
createCopyUrl: Function,
},
}
</script> </script>

View File

@@ -17,8 +17,8 @@ export default {
Github, Github,
Logo, Logo,
Search, Search,
Sidebar Sidebar,
} },
} }
</script> </script>

View File

@@ -18,18 +18,34 @@ export default {
{ rel:'manifest', href:'/site.webmanifest' }, { rel:'manifest', href:'/site.webmanifest' },
{ rel:'icon', type:'image/png', sizes:'16x16', href:'/favicon-16x16.png' }, { rel:'icon', type:'image/png', sizes:'16x16', href:'/favicon-16x16.png' },
{ rel:'icon', type:'image/png', sizes:'32x32', href:'/favicon-32x32.png' }, { rel:'icon', type:'image/png', sizes:'32x32', href:'/favicon-32x32.png' },
{ rel:'apple-touch-icon', sizes:'76x76', href:'/apple-touch-icon.png' } { rel:'apple-touch-icon', sizes:'76x76', href:'/apple-touch-icon.png' },
], ],
link: [ link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
] ],
}, },
/* /*
** Generate dynamic routes ** Generate dynamic routes
*/ */
generate: { generate: {
routes: resources.map(category => category.slug) routes: resources.map(category => category.slug),
},
/**
* Configure ESLint to run on save with hot reloading
*/
build: {
extend(config, ctx) {
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/,
})
}
},
}, },
/* /*
@@ -38,12 +54,12 @@ export default {
loading: { color: '#fff' }, loading: { color: '#fff' },
plugins: [ plugins: [
'~/plugins/i18n.js' '~/plugins/i18n.js',
], ],
/* /*
** Nuxt.js modules ** Nuxt.js modules
*/ */
modules: [ modules: [
'nuxt-clipboard2', 'nuxt-clipboard2',
] ],
} }

781
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,9 @@
"dev": "nuxt", "dev": "nuxt",
"build": "nuxt build", "build": "nuxt build",
"start": "nuxt start", "start": "nuxt start",
"generate": "nuxt generate" "generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore ."
}, },
"dependencies": { "dependencies": {
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
@@ -18,8 +20,15 @@
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^8.6.4", "autoprefixer": "^8.6.4",
"babel-eslint": "^10.0.3",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.3.0",
"eslint-loader": "^3.0.2",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-vue": "^5.2.3",
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"nodemon": "^1.18.9", "nodemon": "^1.18.9",
"prettier": "^1.18.2",
"pug": "^2.0.3", "pug": "^2.0.3",
"pug-plain-loader": "^1.0.0", "pug-plain-loader": "^1.0.0",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",

View File

@@ -10,16 +10,17 @@
</template> </template>
<script> <script>
import Card from "../components/Card"; import Card from '../components/Card'
import TableRow from "../components/TableRow"; import TableRow from '../components/TableRow'
export default { export default {
components: { Card, TableRow },
data() { data() {
return { return {
categoryRouteTitle: this.$route.params.category, categoryRouteTitle: this.$route.params.category,
index: '', index: '',
activeCard: '', activeCard: '',
}; }
}, },
computed: { computed: {
areCardsVisible() { areCardsVisible() {
@@ -29,6 +30,9 @@ export default {
return this.$store.getters['data/sortByTitle'](this.categoryRouteTitle) return this.$store.getters['data/sortByTitle'](this.categoryRouteTitle)
}, },
}, },
created() {
this.activeCard = this.$route.query.card || ''
},
methods: { methods: {
setActiveCard(index) { setActiveCard(index) {
this.activeCard = index this.activeCard = index
@@ -40,15 +44,11 @@ export default {
this.setActiveCard(cleanTitle) this.setActiveCard(cleanTitle)
this.$router.push(path) this.$router.push(path)
} catch (e) { } catch (e) {
console.error(e); console.error(e)
} }
} },
}, },
created() { }
this.activeCard = this.$route.query.card || ''
},
components: { Card, TableRow }
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -11,8 +11,8 @@ export default ({ app, store }) => {
fallbackLocale: 'en', fallbackLocale: 'en',
messages: { messages: {
'en': require('~/locales/en.json'), 'en': require('~/locales/en.json'),
'fr': require('~/locales/fr.json') 'fr': require('~/locales/fr.json'),
} },
}) })
app.i18n.path = (link) => { app.i18n.path = (link) => {

View File

@@ -1,7 +1,5 @@
const join = require('path').join
module.exports = { module.exports = {
plugins: [ plugins: [
require('autoprefixer') require('autoprefixer'),
] ],
} }

View File

@@ -1,14 +1,14 @@
export const state = () => ({ export const state = () => ({
areCardsVisible: true areCardsVisible: true,
}) })
export const getters = { export const getters = {
areCardsVisible: state => state.areCardsVisible areCardsVisible: state => state.areCardsVisible,
} }
export const mutations = { export const mutations = {
toggleCardsVisible(state) { toggleCardsVisible(state) {
if (process.browser) localStorage.setItem('areCardsVisible', !state.areCardsVisible) if (process.browser) localStorage.setItem('areCardsVisible', !state.areCardsVisible)
state.areCardsVisible = !state.areCardsVisible state.areCardsVisible = !state.areCardsVisible
} },
} }

View File

@@ -5,20 +5,20 @@ if (!Array.prototype.flat) {
Object.defineProperty(Array.prototype, 'flat', { Object.defineProperty(Array.prototype, 'flat', {
configurable: true, configurable: true,
value: function flat () { value: function flat () {
var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]); var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0])
return depth ? Array.prototype.reduce.call(this, function (acc, cur) { return depth ? Array.prototype.reduce.call(this, function (acc, cur) {
if (Array.isArray(cur)) { if (Array.isArray(cur)) {
acc.push.apply(acc, flat.call(cur, depth - 1)); acc.push.apply(acc, flat.call(cur, depth - 1))
} else { } else {
acc.push(cur); acc.push(cur)
} }
return acc; return acc
}, []) : Array.prototype.slice.call(this); }, []) : Array.prototype.slice.call(this)
}, },
writable: true writable: true,
}); })
} }
/** /**
@@ -39,14 +39,14 @@ export const state = () => ({
cleanTitle, cleanTitle,
path: `${category.slug}?card=${cleanTitle}`, path: `${category.slug}?card=${cleanTitle}`,
} }
}) }),
})), })),
// List of all tags, duplicates removed // List of all tags, duplicates removed
tags: [...new Set( tags: [...new Set(
resources resources
.map(resource => resource.resources).flat() .map(resource => resource.resources).flat()
.map(resource => resource.tags).flat() .map(resource => resource.tags).flat()
)] )],
}) })
export const getters = { export const getters = {
@@ -64,9 +64,9 @@ export const getters = {
const clone = [...category.resources] const clone = [...category.resources]
return { return {
...category, ...category,
resources: clone.sort(compareTitles) resources: clone.sort(compareTitles),
} }
} },
} }
const compareTitles = (x, y) => { const compareTitles = (x, y) => {

View File

@@ -1,6 +1,6 @@
export const state = () => ({ export const state = () => ({
locales: ['en', 'fr', 'de'], locales: ['en', 'fr', 'de'],
locale: 'en' locale: 'en',
}) })
export const mutations = { export const mutations = {
@@ -8,5 +8,5 @@ export const mutations = {
if (state.locales.indexOf(locale) !== -1) { if (state.locales.indexOf(locale) !== -1) {
state.locale = locale state.locale = locale
} }
} },
} }