Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Convert Standard to eslint-config-standard #1328

Merged
merged 5 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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