Skip to content

Commit 68cd704

Browse files
pi0TheAlexLichter
authored andcommitted
refactor: lint all js blocks in markdown files (nuxt#1681)
1 parent c4fa7e1 commit 68cd704

File tree

254 files changed

+3018
-1306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+3018
-1306
lines changed

.eslintrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"root": true,
3+
"parserOptions": {
4+
"parser": "babel-eslint",
5+
"sourceType": "module"
6+
},
7+
"extends": [
8+
"@nuxtjs"
9+
],
10+
"plugins": [
11+
"markdown"
12+
]
13+
}

de/api/components-nuxt.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ There are 3 ways to handle internal `key` prop of `<router-view/>`.
4343

4444
```js
4545
export default {
46-
key(route) {
47-
return route.fullPath
48-
}
46+
key (route) {
47+
return route.fullPath
48+
}
4949
}
5050
```
5151

de/api/configuration-dev.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const app = require('express')()
3535
const port = process.env.PORT || 3000
3636

3737
// We instantiate Nuxt.js with the options
38-
let config = require('./nuxt.config.js')
38+
const config = require('./nuxt.config.js')
3939
const nuxt = new Nuxt(config)
4040
app.use(nuxt.render)
4141

de/api/configuration-generate.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ const axios = require('axios')
126126

127127
module.exports = {
128128
generate: {
129-
routes: function () {
129+
routes () {
130130
return axios.get('https://my-api/users')
131-
.then((res) => {
132-
return res.data.map((user) => {
133-
return '/users/' + user.id
131+
.then((res) => {
132+
return res.data.map((user) => {
133+
return '/users/' + user.id
134+
})
134135
})
135-
})
136136
}
137137
}
138138
}
@@ -147,15 +147,15 @@ const axios = require('axios')
147147

148148
module.exports = {
149149
generate: {
150-
routes: function (callback) {
150+
routes (callback) {
151151
axios.get('https://my-api/users')
152-
.then((res) => {
153-
var routes = res.data.map((user) => {
154-
return '/users/' + user.id
152+
.then((res) => {
153+
const routes = res.data.map((user) => {
154+
return '/users/' + user.id
155+
})
156+
callback(null, routes)
155157
})
156-
callback(null, routes)
157-
})
158-
.catch(callback)
158+
.catch(callback)
159159
}
160160
}
161161
}
@@ -172,16 +172,16 @@ const axios = require('axios')
172172

173173
module.exports = {
174174
generate: {
175-
routes: function () {
175+
routes () {
176176
return axios.get('https://my-api/users')
177-
.then((res) => {
178-
return res.data.map((user) => {
179-
return {
180-
route: '/users/' + user.id,
181-
payload: user
182-
}
177+
.then((res) => {
178+
return res.data.map((user) => {
179+
return {
180+
route: '/users/' + user.id,
181+
payload: user
182+
}
183+
})
183184
})
184-
})
185185
}
186186
}
187187
}

de/api/configuration-loading.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
setTimeout(() => this.$nuxt.$loading.finish(), 500)
2121
})
2222
}
23-
}
23+
}
2424
```
2525

2626
> If you want to start it in the `mounted` method, make sure to use ` this.$nextTick`, because $loading may not be available immediately.

de/api/configuration-render.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = {
1717
render: {
1818
bundleRenderer: {
1919
directives: {
20-
custom1: function (el, dir) {
20+
custom1 (el, dir) {
2121
// something ...
2222
}
2323
}

de/api/configuration-router.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Example of forcing the scroll position to the top for every routes:
202202
```js
203203
module.exports = {
204204
router: {
205-
scrollBehavior: function (to, from, savedPosition) {
205+
scrollBehavior (to, from, savedPosition) {
206206
return { x: 0, y: 0 }
207207
}
208208
}

de/api/configuration-servermiddleware.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ const serveStatic = require('serve-static')
3232

3333
module.exports = {
3434
serverMiddleware: [
35-
// Will register redirect-ssl npm package
36-
'redirect-ssl',
35+
// Will register redirect-ssl npm package
36+
'redirect-ssl',
3737

38-
// Will register file from project api directory to handle /api/* requires
39-
{ path: '/api', handler: '~/api/index.js' },
38+
// Will register file from project api directory to handle /api/* requires
39+
{ path: '/api', handler: '~/api/index.js' },
4040

41-
// We can create custom instances too
42-
{ path: '/static2', handler: serveStatic(__dirname + '/static2') }
41+
// We can create custom instances too
42+
{ path: '/static2', handler: serveStatic(__dirname + '/static2') }
4343
]
4444
}
4545
```
@@ -58,21 +58,21 @@ Middleware (`api/logger.js`):
5858

5959
```js
6060
module.exports = function (req, res, next) {
61-
// req is the Node.js http request object
62-
console.log(req.path)
63-
64-
// res is the Node.js http response object
65-
66-
// next is a function to call to invoke the next middleware
67-
// Don't forget to call next at the end if your middleware is not an endpoint!
68-
next()
61+
// req is the Node.js http request object
62+
console.log(req.path)
63+
64+
// res is the Node.js http response object
65+
66+
// next is a function to call to invoke the next middleware
67+
// Don't forget to call next at the end if your middleware is not an endpoint!
68+
next()
6969
}
7070
```
7171

7272
Nuxt Config (`nuxt.config.js`):
7373

7474
```js
7575
serverMiddleware: [
76-
'~/api/logger'
76+
'~/api/logger'
7777
]
7878
```

de/api/configuration-vue-config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ description: A config object for Vue.config
1818
export default {
1919
vue: {
2020
config: {
21-
productionTip: true,
22-
devtools: false
21+
productionTip: true,
22+
devtools: false
2323
}
2424
}
2525
}

de/api/internals-module-container.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ All [modules](/guide/modules) will be called within context of `ModuleContainer`
1414
We can register hooks on certain life cycle events.
1515

1616
```js
17-
nuxt.moduleContainer.plugin('ready', async moduleContainer => {
18-
// Do this after all modules where ready
17+
nuxt.moduleContainer.plugin('ready', async (moduleContainer) => {
18+
// Do this after all modules where ready
1919
})
2020
```
2121

2222
Inside [modules](/guide/modules) context we can use this instead:
2323

2424
```js
25-
this.plugin('ready', async moduleContainer => {
26-
// Do this after all modules where ready
25+
this.plugin('ready', async (moduleContainer) => {
26+
// Do this after all modules where ready
2727
})
2828
```
2929

de/api/internals-nuxt.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ This is the core container which allows all modules and classes communicate with
1414
We can register hooks on certain life cycle events.
1515

1616
```js
17-
nuxt.hook('ready', async nuxt => {
18-
// Your custom code here
17+
nuxt.hook('ready', async (nuxt) => {
18+
// Your custom code here
1919
})
2020
```
2121

de/api/internals.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SomeClass extends Tapable {
7676
this.options = nuxt.options
7777
}
7878

79-
someFunction() {
79+
someFunction () {
8080
// We have access to `this.nuxt` and `this.options`
8181
}
8282
}
@@ -99,7 +99,7 @@ class FooClass extends Tapable {
9999
So we can hook into `foo` module like this:
100100

101101
```js
102-
nuxt.hook('foo', foo => {
103-
// ...
102+
nuxt.hook('foo', (foo) => {
103+
// ...
104104
})
105105
```

de/api/nuxt-render-and-get-window.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ config.dev = false
3838
const nuxt = new Nuxt(config)
3939

4040
nuxt.renderAndGetWindow('http://localhost:3000')
41-
.then((window) => {
41+
.then((window) => {
4242
// Display the head `<title>`
43-
console.log(window.document.title)
44-
})
43+
console.log(window.document.title)
44+
})
4545
```

de/api/nuxt-render-route.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ config.dev = false
3535
const nuxt = new Nuxt(config)
3636

3737
new Builder(nuxt)
38-
.build()
39-
.then(() => nuxt.renderRoute('/'))
40-
.then(({ html, error, redirected }) => {
38+
.build()
39+
.then(() => nuxt.renderRoute('/'))
40+
.then(({ html, error, redirected }) => {
4141
// `html` will be always a string
4242

43-
// `error` not null when the error layout is displayed, the error format is:
44-
// { statusCode: 500, message: 'My error message' }
43+
// `error` not null when the error layout is displayed, the error format is:
44+
// { statusCode: 500, message: 'My error message' }
4545

4646
// `redirected` is not `false` when `redirect()` has been used in `data()` or `fetch()`
4747
// { path: '/other-path', query: {}, status: 302 }
48-
})
48+
})
4949
```

de/api/nuxt-render.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ app.use(nuxt.render)
3333
// Build only in dev mode with hot-reloading
3434
if (config.dev) {
3535
new Builder(nuxt).build()
36-
.then(listen)
37-
}
38-
else {
36+
.then(listen)
37+
} else {
3938
listen()
4039
}
4140

42-
function listen() {
41+
function listen () {
4342
// Listen the server
4443
app.listen(port, '0.0.0.0')
4544
console.log('Server listening on `localhost:' + port + '`.')

de/api/pages-transition.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ If the `transition` key is set as a function:
9393
```js
9494
export default {
9595
transition (to, from) {
96-
if (!from) return 'slide-left'
96+
if (!from) { return 'slide-left' }
9797
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
9898
}
9999
}

de/api/pages-validate.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ You can also check some data in your [store](/guide/vuex-store) for example (fil
3434
```js
3535
export default {
3636
validate ({ params, store }) {
37-
  // Check if `params.id` is an existing category
38-
  return store.state.categories.some((category) => category.id === params.id)
37+
// Check if `params.id` is an existing category
38+
return store.state.categories.some(category => category.id === params.id)
3939
}
4040
}
4141
```

de/examples/auth-external-jwt.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ After that make `index.js` in `store` directory like below :
6161
```javascript
6262
import Vuex from 'vuex'
6363

64-
var cookieparser = require('cookieparser')
64+
const cookieparser = require('cookieparser')
6565

6666
const createStore = () => {
6767
return new Vuex.Store({
@@ -77,7 +77,7 @@ const createStore = () => {
7777
nuxtServerInit ({ commit }, { req }) {
7878
let accessToken = null
7979
if (req.headers.cookie) {
80-
var parsed = cookieparser.parse(req.headers.cookie)
80+
const parsed = cookieparser.parse(req.headers.cookie)
8181
accessToken = JSON.parse(parsed.auth)
8282
}
8383
commit('update', accessToken)

de/examples/auth-routes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const store = () => new Vuex.Store({
105105
},
106106

107107
mutations: {
108-
SET_USER: function (state, user) {
108+
SET_USER (state, user) {
109109
state.authUser = user
110110
}
111111
},

de/faq/cached-components.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ To avoid boilerplate, use [Component Cache module](https://github.com/nuxt-commu
2424
['@nuxtjs/component-cache', {
2525
max: 10000,
2626
maxAge: 1000 * 60 * 60
27-
}],
27+
}]
2828
]
2929
}
3030
```

de/faq/extend-webpack.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ You can extend the webpack configuration via the `extend` option in your `nuxt.c
1010
```js
1111
module.exports = {
1212
build: {
13-
extend (config, { isDev, isClient }) {
14-
// ...
15-
}
13+
extend (config, { isDev, isClient }) {
14+
// ...
15+
}
1616
}
1717
}
1818
```

de/faq/postcss-plugins.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = {
1313
postcss: [
1414
require('postcss-nested')(),
1515
require('postcss-responsive-type')(),
16-
require('postcss-hexrgba')(),
16+
require('postcss-hexrgba')()
1717
]
1818
}
1919
}

de/faq/window-document-undefined.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (process.client) {
1818
If you are using this library within multiple files, we recommend that you add it into your [vendor bundle](/api/configuration-build#build-vendor) via `nuxt.config.js`:
1919

2020
```js
21-
build: {
22-
vendor: ['external_library']
23-
}
21+
build: {
22+
vendor: ['external_library']
23+
}
2424
```

de/guide/assets.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Or if in your `pages/index.vue` you use:
3131
It will be compiled into:
3232

3333
```js
34-
createElement('img', { attrs: { src: require('~/assets/image.png') }})
34+
createElement('img', { attrs: { src: require('~/assets/image.png') } })
3535
```
3636

3737
Because `.png` is not a JavaScript file, Nuxt.js configures webpack to use [file-loader](https://github.com/webpack/file-loader) and [url-loader](https://github.com/webpack/url-loader) to handle them for you.

0 commit comments

Comments
 (0)