Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit a364f72

Browse files
committed
chore(lint): lint all supported files
1 parent bc5c373 commit a364f72

29 files changed

+371
-300
lines changed

docs/nuxt.config.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ module.exports = {
44
meta: [
55
{ charset: 'utf-8' },
66
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
7-
{ hid: 'description', name: 'description', content: 'Nuxtent Documentation' }
7+
{
8+
hid: 'description',
9+
name: 'description',
10+
content: 'Nuxtent Documentation'
11+
}
812
],
9-
link: [
10-
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
11-
]
13+
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
1214
},
13-
modules: [
14-
'nuxtent'
15-
],
15+
modules: ['nuxtent'],
1616
css: [
1717
'prismjs/themes/prism-coy.css',
1818
{ src: '~/assets/sass/base.sass', lang: 'sass' }

docs/nuxtent.config.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,33 @@ module.exports = {
66
page: 'guide/_slug',
77
permalink: ':slug',
88
isPost: false,
9-
generate: [
10-
'get',
11-
'getAll'
12-
]
9+
generate: ['get', 'getAll']
1310
},
1411

1512
parsers: {
1613
md: {
1714
highlight: (code, lang) => {
18-
return Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
15+
return Prism.highlight(
16+
code,
17+
Prism.languages[lang] || Prism.languages.markup
18+
)
1919
},
2020
use: [
21-
[externalLinks, {
22-
target: '_blank',
23-
rel: 'noopener'
24-
}]
21+
[
22+
externalLinks,
23+
{
24+
target: '_blank',
25+
rel: 'noopener'
26+
}
27+
]
2528
]
2629
}
2730
},
2831

2932
api: {
30-
baseURL: process.env.NODE_ENV === 'production'
31-
? 'https://nuxtent.now.sh'
32-
: 'http://localhost:3000'
33+
baseURL:
34+
process.env.NODE_ENV === 'production'
35+
? 'https://nuxtent.now.sh'
36+
: 'http://localhost:3000'
3337
}
3438
}

examples/content-navigation/nuxt.config.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ module.exports = {
55
{ charset: 'utf-8' },
66
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
77
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
8-
],
8+
]
99
},
10-
modules: [
11-
'nuxtent'
12-
]
10+
modules: ['nuxtent']
1311
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
content: {
33
page: '/guide/_slug',
4-
permalink: ":slug",
4+
permalink: ':slug',
55
isPost: false
66
}
77
}

examples/custom-build/nuxt.config.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ module.exports = {
55
{ charset: 'utf-8' },
66
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
77
{ hid: 'description', name: 'description', content: 'Nuxt.js project' }
8-
],
8+
]
99
},
10-
modules: [
11-
'nuxtent'
12-
]
10+
modules: ['nuxtent']
1311
}
+13-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
const Prism = require('prismjs')
22

33
module.exports = {
4-
content: { // basic content configuration
4+
content: {
5+
// basic content configuration
56
permalink: ':slug',
67
isPost: false
78
},
89

9-
parser: { // custom parser options
10+
parser: {
11+
// custom parser options
1012
md: {
1113
highlight: (code, lang) => {
12-
return Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
14+
return Prism.highlight(
15+
code,
16+
Prism.languages[lang] || Prism.languages.markup
17+
)
1318
}
1419
}
1520
},
1621

17-
api: { // custom url for development and production builds
18-
baseURL: process.env.NODE_ENV ?
19-
'https://production-url.now.sh' :
20-
'http://localhost:3000'
22+
api: {
23+
// custom url for development and production builds
24+
baseURL: process.env.NODE_ENV
25+
? 'https://production-url.now.sh'
26+
: 'http://localhost:3000'
2127
}
2228
}

examples/i18n/nuxt.config.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
module.exports = {
22
loading: { color: 'cyan' },
3-
modules: [
4-
'nuxtent'
5-
]
3+
modules: ['nuxtent']
64
}

examples/i18n/nuxtent.config.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@ const contentOptions = {
33
}
44

55
module.exports = {
6-
content: [
7-
['en', contentOptions],
8-
['fe', contentOptions]
9-
]
6+
content: [['en', contentOptions], ['fe', contentOptions]]
107
}
+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module.exports = {
2-
modules: [
3-
'nuxtent'
4-
]
2+
modules: ['nuxtent']
53
}

examples/markdown-components/nuxtent.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
content: {
33
page: '/_slug',
4-
permalink: "/:slug",
4+
permalink: '/:slug',
55
isPost: false,
66
generate: ['get']
77
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module.exports = {
2-
modules: [
3-
'nuxtent'
4-
]
2+
modules: ['nuxtent']
53
}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
module.exports = {
22
content: [
3-
['posts', {
4-
page: '/_post',
5-
permalink: ":year/:slug",
6-
generate: ['get', 'getAll']
7-
}],
8-
['projects', {
9-
page: '/projects/slug',
10-
permalink: "/:slug",
11-
isPost: false,
12-
generate: ['get', 'getAll']
13-
}]
3+
[
4+
'posts',
5+
{
6+
page: '/_post',
7+
permalink: ':year/:slug',
8+
generate: ['get', 'getAll']
9+
}
10+
],
11+
[
12+
'projects',
13+
{
14+
page: '/projects/slug',
15+
permalink: '/:slug',
16+
isPost: false,
17+
generate: ['get', 'getAll']
18+
}
19+
]
1420
]
1521
}

examples/single-content-type/nuxt.config.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module.exports = {
2-
modules: [
3-
'nuxtent'
4-
],
2+
modules: ['nuxtent'],
53
nuxtent: {
64
content: {
75
page: '/_post',
86
permalink: ':year/:slug',
9-
generate: [ // assets to generate static build
10-
'get', 'getAll'
7+
generate: [
8+
// assets to generate static build
9+
'get',
10+
'getAll'
1111
]
1212
}
1313
}

examples/sitemap/nuxt.config.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
const axios = require('axios')
22

33
module.exports = {
4-
modules: [
5-
'nuxtent',
6-
'@nuxtjs/sitemap'
7-
],
4+
modules: ['nuxtent', '@nuxtjs/sitemap'],
85
nuxtent: {
96
content: {
107
page: '/_post',
118
permalink: ':year/:slug',
12-
generate: [ // assets to generate static build
13-
'get', 'getAll'
9+
generate: [
10+
// assets to generate static build
11+
'get',
12+
'getAll'
1413
]
1514
}
1615
},
1716
sitemap: {
1817
generate: true,
1918
routes: function () {
20-
return axios.get('http://localhost:3000/content-api')
21-
.then((res) => {
22-
return res.data.map((page) => page.path )
19+
return axios.get('http://localhost:3000/content-api').then(res => {
20+
return res.data.map(page => page.path)
2321
})
2422
}
2523
}

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const nuxtentModule = require("./dist/module.js");
1+
const nuxtentModule = require('./dist/module.js')
22

3-
module.exports = nuxtentModule.default;
4-
module.exports.meta = nuxtentModule.meta;
3+
module.exports = nuxtentModule.default
4+
module.exports.meta = nuxtentModule.meta

lib/content/api.js

+18-11
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ export default function createRouter (options) {
1111

1212
// for multiple content types, show the content configuration in the root request
1313
if (!options.content['/']) {
14-
router.use("/", new Router().get('/', (req, res) => {
15-
response(res).json({
16-
'content-endpoints': Object.keys(options.content)
14+
router.use(
15+
'/',
16+
new Router().get('/', (req, res) => {
17+
response(res).json({
18+
'content-endpoints': Object.keys(options.content)
19+
})
1720
})
18-
}))
21+
)
1922
}
2023

2124
Object.keys(options.content).forEach(dirName => {
@@ -41,30 +44,32 @@ function curryResponseHandler (endpoint, options) {
4144

4245
logRequest(permalink, api.serverPrefix, api.baseURL)
4346

44-
if (permalink === '/') { // request multiple pages from directory
47+
if (permalink === '/') {
48+
// request multiple pages from directory
4549
if (between) send.json(db.findBetween(between, query))
4650
else if (only) send.json(db.findOnly(only, query))
4751
else send.json(db.findAll(query))
48-
} else { // request single page
52+
} else {
53+
// request single page
4954
if (db.exists(permalink)) send.json(db.find(permalink, query))
5055
else send.notFound()
5156
}
5257
}
5358
}
5459

55-
export const response = (res) => ({
56-
json(data) {
60+
export const response = res => ({
61+
json (data) {
5762
res.setHeader('Content-Type', 'application/json')
5863
res.end(JSON.stringify(data), 'utf-8')
5964
console.log(` Response sent successfully.`)
6065
},
61-
error(err) {
66+
error (err) {
6267
console.log(` Failed to send response.`, error)
6368
res.statusCode = 500
6469
res.statusMessage = 'Internal Server Error'
6570
res.end(err.stack || String(err))
6671
},
67-
notFound() {
72+
notFound () {
6873
console.log(` Page not found.`)
6974
res.statusCode = 404
7075
res.statusMessage = 'Not Found'
@@ -73,6 +78,8 @@ export const response = (res) => ({
7378
})
7479

7580
function logRequest (permalink, apiPrefix, baseURL) {
76-
console.log(`${chalk.blue(apiPrefix)} ${chalk.green('GET')} ${baseURL + permalink}`)
81+
console.log(
82+
`${chalk.blue(apiPrefix)} ${chalk.green('GET')} ${baseURL + permalink}`
83+
)
7784
return permalink
7885
}

0 commit comments

Comments
 (0)