Skip to content

Commit 1cbd83d

Browse files
committed
Eslint code
1 parent 7c964d7 commit 1cbd83d

18 files changed

+77
-32
lines changed

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_size = 2
6+
indent_style = space
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintrc.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
root: true,
3+
parser: 'babel-eslint',
4+
parserOptions: {
5+
sourceType: 'module'
6+
},
7+
env: {
8+
browser: true,
9+
node: true
10+
},
11+
extends: 'standard',
12+
// required to lint *.vue files
13+
plugins: [
14+
'html'
15+
],
16+
// add your custom rules here
17+
rules: {
18+
// allow paren-less arrow functions
19+
'arrow-parens': 0,
20+
// allow async-await
21+
'generator-star-spacing': 0,
22+
// allow debugger during development
23+
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
24+
// do not allow console.logs etc...
25+
'no-console': 2
26+
},
27+
globals: {}
28+
}

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ npm-debug.log
88
# other
99
.nuxt
1010
dist
11-
static/docs

components/Affix.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default {
6060
},
6161
computed: {
6262
visible () { return this.$store.state.visibleAffix },
63-
path() { return this.$route.path.slice(-1) === '/' ? this.$route.path.slice(0, -1) : this.$route.path },
63+
path () { return this.$route.path.slice(-1) === '/' ? this.$route.path.slice(0, -1) : this.$route.path },
6464
menu () { return '/' + this.category },
6565
contents () {
6666
var c = []
@@ -86,8 +86,8 @@ export default {
8686
toggle () { this.$store.commit('toggle', 'visibleAffix') },
8787
scrolled () {
8888
var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
89-
var doc = document.documentElement;
90-
var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
89+
var doc = document.documentElement
90+
var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)
9191
var el = this.contents.find((pos) => {
9292
return pos > top + (h / 2)
9393
})
@@ -99,8 +99,8 @@ export default {
9999
var el = document.getElementById(id.slice(1))
100100
if (!el) return
101101
var to = el.offsetTop - 25
102-
var doc = document.documentElement;
103-
var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
102+
var doc = document.documentElement
103+
var top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)
104104
var diff = (to > top ? to - top : top - to) / 25
105105
var i = 0
106106
window.clearInterval(this.setInter)

components/FilesTree.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ export default {
6262
return this.content
6363
},
6464
breadcrumb () {
65-
return this.currentFile.path.replace('examples/'+this.example, '')
65+
return this.currentFile.path.replace('examples/' + this.example, '')
6666
},
6767
isImage () {
68-
if (this.currentFile && /[^\s]+\.(jpe?g|png|gif|bmp)$/i.test(this.currentFile.path)){
68+
if (this.currentFile && /[^\s]+\.(jpe?g|png|gif|bmp)$/i.test(this.currentFile.path)) {
6969
return true
7070
}
7171
return false

components/Footer.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="Footer__Author container">
77
{{ $store.state.lang.footer.authors }}:
88
<a href="https://github.com/Atinux" target="_blank">@Atinux</a>
9-
&
9+
&amp;
1010
<a href="https://github.com/alexchopin" target="_blank">@alexchopin</a>
1111
</div>
1212
</footer>

components/Header.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default {
7676
{ iso: 'ru', class: 'flag-ru', url: 'https://ru.nuxtjs.org' }
7777
]
7878
},
79-
ecosystemLinks() {
79+
ecosystemLinks () {
8080
return [
8181
{
8282
name: this.$store.state.lang.links.github,

components/RecursiveList.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default {
5050
})
5151
if (!this.currentFile) {
5252
let f = res.data.find((file) => {
53-
return file.name === "package.json"
53+
return file.name === 'package.json'
5454
})
5555
if (f) this.changeFile(f)
5656
}

layouts/default.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import Navbar from '~components/Header.vue'
1212
1313
export default {
14-
watch:{
14+
watch: {
1515
$route: 'setStore'
1616
},
1717
computed: {

package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"nuxt": "latest"
1414
},
1515
"devDependencies": {
16+
"babel-eslint": "^7.1.1",
17+
"eslint": "^3.13.1",
18+
"eslint-config-standard": "^6.2.1",
19+
"eslint-plugin-html": "^1.7.0",
20+
"eslint-plugin-promise": "^3.4.0",
21+
"eslint-plugin-standard": "^2.0.1",
1622
"node-sass": "^3.13.0",
1723
"push-dir": "^0.4.1",
1824
"sass-loader": "^4.0.2"
@@ -23,7 +29,9 @@
2329
"start": "nuxt start",
2430
"generate": "nuxt generate",
2531
"deploy": "push-dir --dir=dist --branch=gh-pages --cleanup",
26-
"deploy-ru": "surge dist/ ru.nuxtjs.org"
32+
"deploy-ru": "surge dist/ ru.nuxtjs.org",
33+
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --ignore-pattern plugins/ga.js .",
34+
"precommit": "npm run lint"
2735
},
2836
"repository": {
2937
"type": "git",

pages/api/_slug.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export default {
3737
if (store.state.lang.iso === 'ru') {
3838
data.docLink = `https://github.com/translation-gang/ru.docs.nuxtjs/blob/translation-ru${path}.md`
3939
}
40-
if (!data.attrs.title) console.error(`[${path}] Please define a title in the front matter.`)
41-
if (!data.attrs.description) console.error(`[${path}] Please define a description in the front matter.`)
40+
if (!data.attrs.title) console.error(`[${path}] Please define a title in the front matter.`) // eslint-disable-line no-console
41+
if (!data.attrs.description) console.error(`[${path}] Please define a description in the front matter.`) // eslint-disable-line no-console
4242
return data
4343
},
4444
scrollToTop: true,

pages/examples/_slug.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export default {
5555
}
5656
data.attrs = res.data.attrs
5757
data.body = res.data.body
58-
if (!data.attrs.title) console.error(`[${path}] Please define a title in the front matter.`)
59-
if (!data.attrs.description) console.error(`[${path}] Please define a description in the front matter.`)
58+
if (!data.attrs.title) console.error(`[${path}] Please define a title in the front matter.`) // eslint-disable-line no-console
59+
if (!data.attrs.description) console.error(`[${path}] Please define a description in the front matter.`) // eslint-disable-line no-console
6060
return data
6161
},
6262
computed: {

pages/faq/_slug.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export default {
3737
if (store.state.lang.iso === 'ru') {
3838
data.docLink = `https://github.com/translation-gang/ru.docs.nuxtjs/blob/translation-ru${path}.md`
3939
}
40-
if (!data.attrs.title) console.error(`[${path}] Please define a title in the front matter.`)
41-
if (!data.attrs.description) console.error(`[${path}] Please define a description in the front matter.`)
40+
if (!data.attrs.title) console.error(`[${path}] Please define a title in the front matter.`) // eslint-disable-line no-console
41+
if (!data.attrs.description) console.error(`[${path}] Please define a description in the front matter.`) // eslint-disable-line no-console
4242
return data
4343
},
4444
scrollToTop: true,

pages/guide/_slug.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export default {
4141
if (store.state.lang.iso === 'ru') {
4242
data.docLink = `https://github.com/translation-gang/ru.docs.nuxtjs/blob/translation-ru${path}.md`
4343
}
44-
if (!data.attrs.title) console.error(`[${path}] Please define a title in the front matter.`)
45-
if (!data.attrs.description) console.error(`[${path}] Please define a description in the front matter.`)
44+
if (!data.attrs.title) console.error(`[${path}] Please define a title in the front matter.`) // eslint-disable-line no-console
45+
if (!data.attrs.description) console.error(`[${path}] Please define a description in the front matter.`) // eslint-disable-line no-console
4646
return data
4747
},
4848
scrollToTop: true,

pages/guide/release-notes.vue

-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ import HtmlParser from '~components/HtmlParser.vue'
1818
1919
export default {
2020
data () {
21-
// Default data
22-
let data = {
23-
releases: []
24-
}
2521
return axios({
2622
url: 'https://api.github.com/repos/nuxt/nuxt.js/releases',
2723
headers: {

plugins/ga.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
if (process.BROWSER_BUILD && process.env.NODE_ENV === 'production') {
22
// Include Google Analytics
3+
/* eslint no-empty: ["comma-spacing"] */
34
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
45
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
56
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

plugins/marked.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import marked, { Renderer } from 'marked'
22
import highlightjs from 'highlight.js'
33

4-
const renderer = new Renderer();
4+
const renderer = new Renderer()
55
renderer.code = (code, language) => {
6-
const validLang = !!(language && highlightjs.getLanguage(language));
7-
const highlighted = validLang ? highlightjs.highlight(language, code).value : code;
8-
return `<pre><code class="hljs ${language}">${highlighted}</code></pre>`;
9-
};
10-
marked.setOptions({ renderer });
6+
const validLang = !!(language && highlightjs.getLanguage(language))
7+
const highlighted = validLang ? highlightjs.highlight(language, code).value : code
8+
return `<pre><code class="hljs ${language}">${highlighted}</code></pre>`
9+
}
10+
marked.setOptions({ renderer })

store/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const store = new Vuex.Store({
3030
const resMenu = await axios(state.apiURI + '/menu/' + state._lang)
3131
state.menu = resMenu.data
3232
} catch (e) {
33-
console.error('Error on [nuxtServerInit] action, please run the docs server.')
33+
console.error('Error on [nuxtServerInit] action, please run the docs server.') // eslint-disable-line no-console
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)