Skip to content

Commit b6de7c6

Browse files
authored
chore: Convert Standard to eslint-config-standard (github#1328)
* chore: Move standard to ESLint config * fix: auto-fix ESLint indent issues * fix: ESLint prefer-regex-literals * fix: ESLint array-callback-return - .filter must return a boolean value - .map replaced with forEach when the value isn't used * fix: ESLint no-extra-semi
1 parent 4d46495 commit b6de7c6

14 files changed

+557
-812
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.eslintrc.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
commonjs: true,
5+
es2020: true,
6+
node: true
7+
},
8+
parser: 'babel-eslint',
9+
extends: [
10+
'eslint:recommended',
11+
'standard'
12+
],
13+
parserOptions: {
14+
ecmaVersion: 11
15+
},
16+
rules: {
17+
},
18+
overrides: [
19+
{
20+
files: [
21+
'**/tests/**/*.js'
22+
],
23+
env: {
24+
jest: true
25+
}
26+
}
27+
]
28+
}

.github/workflows/js-lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
cancel_others: 'false'
2323
github_token: ${{ github.token }}
24-
paths: '["**/*.js", "package*.json", ".github/workflows/js-lint.yml"]'
24+
paths: '["**/*.js", "package*.json", ".github/workflows/js-lint.yml", ".eslint*"]'
2525

2626
lint:
2727
runs-on: ubuntu-latest
@@ -53,7 +53,7 @@ jobs:
5353
run: npm ci
5454

5555
- name: Run linter
56-
run: npx standard
56+
run: npx eslint .
5757

5858
- name: Check dependencies
5959
run: npm run check-deps

.github/workflows/test-translations.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: npm ci
3939

4040
- name: Run linter
41-
run: npx standard
41+
run: npx eslint .
4242

4343
- name: Check dependencies
4444
run: npm run check-deps

lib/redirects/get-docs-path-from-developer-path.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ module.exports = function getDocsPathFromDeveloperPath (oldDeveloperPath, allRed
4343
// GraphQL paths rarely have underscores, but when they do, they are preserved (`__directive`).
4444
fragment = newPath.includes('/v3/')
4545
? lastSegment
46-
.replace(/_/g, '-')
47-
// this is a special oneoff replacement
48-
.replace('org-pre-receive-hooks', 'organization-pre-receive-hooks')
46+
.replace(/_/g, '-')
47+
// this is a special oneoff replacement
48+
.replace('org-pre-receive-hooks', 'organization-pre-receive-hooks')
4949
: lastSegment
5050
}
5151

lib/remove-liquid-statements.js

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ function removeLiquidOnly (content, allLiquidBlocks, regexes) {
9999
if (block.match(regexes.andGreaterThanVersionToDeprecate2)) return firstIf[0] === block.match(regexes.andGreaterThanVersionToDeprecate2)[0]
100100
if (block.match(regexes.notEqualsVersionToDeprecate)) return firstIf[0] === block.match(regexes.notEqualsVersionToDeprecate)[0]
101101
if (block.match(regexes.andNotEqualsVersionToDeprecate)) return firstIf[0] === block.match(regexes.andNotEqualsVersionToDeprecate)[0]
102+
return false
102103
})
103104

104105
blocksToUpdate.forEach(block => {
@@ -182,6 +183,7 @@ function removeLiquidAndContent (content, allLiquidBlocks, regexes) {
182183
const firstIf = block.match(firstIfRegex)
183184
if (block.match(regexes.lessThanNextOldestVersion)) return firstIf[0] === block.match(regexes.lessThanNextOldestVersion)[0]
184185
if (block.match(regexes.equalsVersionToDeprecate)) return firstIf[0] === block.match(regexes.equalsVersionToDeprecate)[0]
186+
return false
185187
})
186188

187189
blocksToRemove.forEach(block => {

lib/site-tree.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ const allVersions = Object.keys(require('./all-versions'))
1818
module.exports = async function buildSiteTree (pages, site, redirects) {
1919
const siteTree = {}
2020

21-
languageCodes.map(languageCode => {
21+
languageCodes.forEach(languageCode => {
2222
siteTree[languageCode] = {}
2323

24-
allVersions.map(version => {
24+
allVersions.forEach(version => {
2525
siteTree[languageCode][version] = {}
2626
const productTree = {}
2727

28-
products.map(item => {
28+
products.forEach(item => {
2929
const product = { title: item.name }
3030

3131
// return early if the product has external docs, like Atom
@@ -60,7 +60,7 @@ function buildCategoriesTree (tocItems, productHref, pages, redirects, version,
6060
const categoryTree = {}
6161

6262
// for every category in a product TOC...
63-
tocItems.map(item => {
63+
tocItems.forEach(item => {
6464
const category = {}
6565

6666
const categoryHref = path.join(productHref, item.href)
@@ -110,7 +110,7 @@ function buildMaptopicsTree (tocItems, categoryHref, pages, redirects, version,
110110
// for every maptopic in a category TOC...
111111
tocItems
112112
.filter(item => item.type === 'maptopic')
113-
.map(item => {
113+
.forEach(item => {
114114
const maptopic = {}
115115

116116
const maptopicHref = path.join(categoryHref, item.href)
@@ -155,7 +155,7 @@ function buildArticlesTree (tocItems, categoryHref, pages, redirects, version, l
155155
if (!tocItems) return articleTree
156156

157157
// for every article in a maptopic (or category) TOC...
158-
tocItems.map(item => {
158+
tocItems.forEach(item => {
159159
const article = {}
160160

161161
const articleHref = path.join(categoryHref, item.href)
@@ -194,5 +194,6 @@ function getChildArticles (tocItems, maptopicPath) {
194194
} else {
195195
if (withinMaptopic) return item.href
196196
}
197+
return false
197198
})
198199
}

lib/warm-server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = async function warmServer () {
88
}
99

1010
// Promise.all is used to load multiple things in parallel
11-
;[pages, site, earlyAccessPaths] = await Promise.all([
11+
[pages, site, earlyAccessPaths] = await Promise.all([
1212
require('./pages')(),
1313
require('./site-data')(),
1414
fetchEarlyAccessPaths()

0 commit comments

Comments
 (0)