Skip to content

Commit

Permalink
chore: Convert Standard to eslint-config-standard (#1328)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nschonni authored Nov 17, 2020
1 parent 4d46495 commit b6de7c6
Show file tree
Hide file tree
Showing 14 changed files with 557 additions and 812 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2020: true,
node: true
},
parser: 'babel-eslint',
extends: [
'eslint:recommended',
'standard'
],
parserOptions: {
ecmaVersion: 11
},
rules: {
},
overrides: [
{
files: [
'**/tests/**/*.js'
],
env: {
jest: true
}
}
]
}
4 changes: 2 additions & 2 deletions .github/workflows/js-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
cancel_others: 'false'
github_token: ${{ github.token }}
paths: '["**/*.js", "package*.json", ".github/workflows/js-lint.yml"]'
paths: '["**/*.js", "package*.json", ".github/workflows/js-lint.yml", ".eslint*"]'

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
run: npm ci

- name: Run linter
run: npx standard
run: npx eslint .

- name: Check dependencies
run: npm run check-deps
2 changes: 1 addition & 1 deletion .github/workflows/test-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: npm ci

- name: Run linter
run: npx standard
run: npx eslint .

- name: Check dependencies
run: npm run check-deps
Expand Down
6 changes: 3 additions & 3 deletions lib/redirects/get-docs-path-from-developer-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ module.exports = function getDocsPathFromDeveloperPath (oldDeveloperPath, allRed
// GraphQL paths rarely have underscores, but when they do, they are preserved (`__directive`).
fragment = newPath.includes('/v3/')
? lastSegment
.replace(/_/g, '-')
// this is a special oneoff replacement
.replace('org-pre-receive-hooks', 'organization-pre-receive-hooks')
.replace(/_/g, '-')
// this is a special oneoff replacement
.replace('org-pre-receive-hooks', 'organization-pre-receive-hooks')
: lastSegment
}

Expand Down
2 changes: 2 additions & 0 deletions lib/remove-liquid-statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function removeLiquidOnly (content, allLiquidBlocks, regexes) {
if (block.match(regexes.andGreaterThanVersionToDeprecate2)) return firstIf[0] === block.match(regexes.andGreaterThanVersionToDeprecate2)[0]
if (block.match(regexes.notEqualsVersionToDeprecate)) return firstIf[0] === block.match(regexes.notEqualsVersionToDeprecate)[0]
if (block.match(regexes.andNotEqualsVersionToDeprecate)) return firstIf[0] === block.match(regexes.andNotEqualsVersionToDeprecate)[0]
return false
})

blocksToUpdate.forEach(block => {
Expand Down Expand Up @@ -182,6 +183,7 @@ function removeLiquidAndContent (content, allLiquidBlocks, regexes) {
const firstIf = block.match(firstIfRegex)
if (block.match(regexes.lessThanNextOldestVersion)) return firstIf[0] === block.match(regexes.lessThanNextOldestVersion)[0]
if (block.match(regexes.equalsVersionToDeprecate)) return firstIf[0] === block.match(regexes.equalsVersionToDeprecate)[0]
return false
})

blocksToRemove.forEach(block => {
Expand Down
13 changes: 7 additions & 6 deletions lib/site-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const allVersions = Object.keys(require('./all-versions'))
module.exports = async function buildSiteTree (pages, site, redirects) {
const siteTree = {}

languageCodes.map(languageCode => {
languageCodes.forEach(languageCode => {
siteTree[languageCode] = {}

allVersions.map(version => {
allVersions.forEach(version => {
siteTree[languageCode][version] = {}
const productTree = {}

products.map(item => {
products.forEach(item => {
const product = { title: item.name }

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

// for every category in a product TOC...
tocItems.map(item => {
tocItems.forEach(item => {
const category = {}

const categoryHref = path.join(productHref, item.href)
Expand Down Expand Up @@ -110,7 +110,7 @@ function buildMaptopicsTree (tocItems, categoryHref, pages, redirects, version,
// for every maptopic in a category TOC...
tocItems
.filter(item => item.type === 'maptopic')
.map(item => {
.forEach(item => {
const maptopic = {}

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

// for every article in a maptopic (or category) TOC...
tocItems.map(item => {
tocItems.forEach(item => {
const article = {}

const articleHref = path.join(categoryHref, item.href)
Expand Down Expand Up @@ -194,5 +194,6 @@ function getChildArticles (tocItems, maptopicPath) {
} else {
if (withinMaptopic) return item.href
}
return false
})
}
2 changes: 1 addition & 1 deletion lib/warm-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = async function warmServer () {
}

// Promise.all is used to load multiple things in parallel
;[pages, site, earlyAccessPaths] = await Promise.all([
[pages, site, earlyAccessPaths] = await Promise.all([
require('./pages')(),
require('./site-data')(),
fetchEarlyAccessPaths()
Expand Down
Loading

2 comments on commit b6de7c6

@naataliie1

This comment was marked as spam.

@naataliie1

This comment was marked as spam.

Please sign in to comment.