chore: Convert Standard to eslint-config-standard (#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
This commit is contained in:
1
.eslintignore
Normal file
1
.eslintignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dist/
|
||||||
28
.eslintrc.js
Normal file
28
.eslintrc.js
Normal file
@@ -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
.github/workflows/js-lint.yml
vendored
4
.github/workflows/js-lint.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
cancel_others: 'false'
|
cancel_others: 'false'
|
||||||
github_token: ${{ github.token }}
|
github_token: ${{ github.token }}
|
||||||
paths: '["**/*.js", "package*.json", ".github/workflows/js-lint.yml"]'
|
paths: '["**/*.js", "package*.json", ".github/workflows/js-lint.yml", ".eslint*"]'
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -53,7 +53,7 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Run linter
|
- name: Run linter
|
||||||
run: npx standard
|
run: npx eslint .
|
||||||
|
|
||||||
- name: Check dependencies
|
- name: Check dependencies
|
||||||
run: npm run check-deps
|
run: npm run check-deps
|
||||||
|
|||||||
2
.github/workflows/test-translations.yml
vendored
2
.github/workflows/test-translations.yml
vendored
@@ -38,7 +38,7 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Run linter
|
- name: Run linter
|
||||||
run: npx standard
|
run: npx eslint .
|
||||||
|
|
||||||
- name: Check dependencies
|
- name: Check dependencies
|
||||||
run: npm run check-deps
|
run: npm run check-deps
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ module.exports = function getDocsPathFromDeveloperPath (oldDeveloperPath, allRed
|
|||||||
// GraphQL paths rarely have underscores, but when they do, they are preserved (`__directive`).
|
// GraphQL paths rarely have underscores, but when they do, they are preserved (`__directive`).
|
||||||
fragment = newPath.includes('/v3/')
|
fragment = newPath.includes('/v3/')
|
||||||
? lastSegment
|
? lastSegment
|
||||||
.replace(/_/g, '-')
|
.replace(/_/g, '-')
|
||||||
// this is a special oneoff replacement
|
// this is a special oneoff replacement
|
||||||
.replace('org-pre-receive-hooks', 'organization-pre-receive-hooks')
|
.replace('org-pre-receive-hooks', 'organization-pre-receive-hooks')
|
||||||
: lastSegment
|
: lastSegment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.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.notEqualsVersionToDeprecate)) return firstIf[0] === block.match(regexes.notEqualsVersionToDeprecate)[0]
|
||||||
if (block.match(regexes.andNotEqualsVersionToDeprecate)) return firstIf[0] === block.match(regexes.andNotEqualsVersionToDeprecate)[0]
|
if (block.match(regexes.andNotEqualsVersionToDeprecate)) return firstIf[0] === block.match(regexes.andNotEqualsVersionToDeprecate)[0]
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
blocksToUpdate.forEach(block => {
|
blocksToUpdate.forEach(block => {
|
||||||
@@ -182,6 +183,7 @@ function removeLiquidAndContent (content, allLiquidBlocks, regexes) {
|
|||||||
const firstIf = block.match(firstIfRegex)
|
const firstIf = block.match(firstIfRegex)
|
||||||
if (block.match(regexes.lessThanNextOldestVersion)) return firstIf[0] === block.match(regexes.lessThanNextOldestVersion)[0]
|
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]
|
if (block.match(regexes.equalsVersionToDeprecate)) return firstIf[0] === block.match(regexes.equalsVersionToDeprecate)[0]
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
blocksToRemove.forEach(block => {
|
blocksToRemove.forEach(block => {
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ const allVersions = Object.keys(require('./all-versions'))
|
|||||||
module.exports = async function buildSiteTree (pages, site, redirects) {
|
module.exports = async function buildSiteTree (pages, site, redirects) {
|
||||||
const siteTree = {}
|
const siteTree = {}
|
||||||
|
|
||||||
languageCodes.map(languageCode => {
|
languageCodes.forEach(languageCode => {
|
||||||
siteTree[languageCode] = {}
|
siteTree[languageCode] = {}
|
||||||
|
|
||||||
allVersions.map(version => {
|
allVersions.forEach(version => {
|
||||||
siteTree[languageCode][version] = {}
|
siteTree[languageCode][version] = {}
|
||||||
const productTree = {}
|
const productTree = {}
|
||||||
|
|
||||||
products.map(item => {
|
products.forEach(item => {
|
||||||
const product = { title: item.name }
|
const product = { title: item.name }
|
||||||
|
|
||||||
// return early if the product has external docs, like Atom
|
// return early if the product has external docs, like Atom
|
||||||
@@ -60,7 +60,7 @@ function buildCategoriesTree (tocItems, productHref, pages, redirects, version,
|
|||||||
const categoryTree = {}
|
const categoryTree = {}
|
||||||
|
|
||||||
// for every category in a product TOC...
|
// for every category in a product TOC...
|
||||||
tocItems.map(item => {
|
tocItems.forEach(item => {
|
||||||
const category = {}
|
const category = {}
|
||||||
|
|
||||||
const categoryHref = path.join(productHref, item.href)
|
const categoryHref = path.join(productHref, item.href)
|
||||||
@@ -110,7 +110,7 @@ function buildMaptopicsTree (tocItems, categoryHref, pages, redirects, version,
|
|||||||
// for every maptopic in a category TOC...
|
// for every maptopic in a category TOC...
|
||||||
tocItems
|
tocItems
|
||||||
.filter(item => item.type === 'maptopic')
|
.filter(item => item.type === 'maptopic')
|
||||||
.map(item => {
|
.forEach(item => {
|
||||||
const maptopic = {}
|
const maptopic = {}
|
||||||
|
|
||||||
const maptopicHref = path.join(categoryHref, item.href)
|
const maptopicHref = path.join(categoryHref, item.href)
|
||||||
@@ -155,7 +155,7 @@ function buildArticlesTree (tocItems, categoryHref, pages, redirects, version, l
|
|||||||
if (!tocItems) return articleTree
|
if (!tocItems) return articleTree
|
||||||
|
|
||||||
// for every article in a maptopic (or category) TOC...
|
// for every article in a maptopic (or category) TOC...
|
||||||
tocItems.map(item => {
|
tocItems.forEach(item => {
|
||||||
const article = {}
|
const article = {}
|
||||||
|
|
||||||
const articleHref = path.join(categoryHref, item.href)
|
const articleHref = path.join(categoryHref, item.href)
|
||||||
@@ -194,5 +194,6 @@ function getChildArticles (tocItems, maptopicPath) {
|
|||||||
} else {
|
} else {
|
||||||
if (withinMaptopic) return item.href
|
if (withinMaptopic) return item.href
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module.exports = async function warmServer () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Promise.all is used to load multiple things in parallel
|
// 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('./pages')(),
|
||||||
require('./site-data')(),
|
require('./site-data')(),
|
||||||
fetchEarlyAccessPaths()
|
fetchEarlyAccessPaths()
|
||||||
|
|||||||
1219
package-lock.json
generated
1219
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@@ -91,6 +91,11 @@
|
|||||||
"del": "^4.1.1",
|
"del": "^4.1.1",
|
||||||
"dependency-check": "^4.1.0",
|
"dependency-check": "^4.1.0",
|
||||||
"domwaiter": "^1.1.0",
|
"domwaiter": "^1.1.0",
|
||||||
|
"eslint": "^7.13.0",
|
||||||
|
"eslint-config-standard": "^16.0.1",
|
||||||
|
"eslint-plugin-import": "^2.22.1",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
"eslint-plugin-promise": "^4.2.1",
|
||||||
"event-to-promise": "^0.8.0",
|
"event-to-promise": "^0.8.0",
|
||||||
"graphql": "^14.5.8",
|
"graphql": "^14.5.8",
|
||||||
"heroku-client": "^3.1.0",
|
"heroku-client": "^3.1.0",
|
||||||
@@ -116,7 +121,6 @@
|
|||||||
"replace": "^1.2.0",
|
"replace": "^1.2.0",
|
||||||
"revalidator": "^0.3.1",
|
"revalidator": "^0.3.1",
|
||||||
"robots-parser": "^2.1.1",
|
"robots-parser": "^2.1.1",
|
||||||
"standard": "^14.3.1",
|
|
||||||
"start-server-and-test": "^1.11.3",
|
"start-server-and-test": "^1.11.3",
|
||||||
"supertest": "^4.0.2",
|
"supertest": "^4.0.2",
|
||||||
"webpack-dev-middleware": "^3.7.2",
|
"webpack-dev-middleware": "^3.7.2",
|
||||||
@@ -127,8 +131,8 @@
|
|||||||
"dev": "npm start",
|
"dev": "npm start",
|
||||||
"build": "cross-env NODE_ENV=production npx webpack --mode production",
|
"build": "cross-env NODE_ENV=production npx webpack --mode production",
|
||||||
"start-all-languages": "cross-env NODE_ENV=development nodemon server.js",
|
"start-all-languages": "cross-env NODE_ENV=development nodemon server.js",
|
||||||
"lint": "standard --fix && prettier -w \"**/*.{yml,yaml}\"",
|
"lint": "eslint --fix . && prettier -w \"**/*.{yml,yaml}\"",
|
||||||
"test": "jest && standard && prettier -c \"**/*.{yml,yaml}\" && npm run check-deps",
|
"test": "jest && eslint . && prettier -c \"**/*.{yml,yaml}\" && npm run check-deps",
|
||||||
"prebrowser-test": "npm run build",
|
"prebrowser-test": "npm run build",
|
||||||
"browser-test": "start-server-and-test browser-test-server 4001 browser-test-tests",
|
"browser-test": "start-server-and-test browser-test-server 4001 browser-test-tests",
|
||||||
"browser-test-server": "cross-env NODE_ENV=production ENABLED_LANGUAGES='en,ja' PORT=4001 node server.js",
|
"browser-test-server": "cross-env NODE_ENV=production ENABLED_LANGUAGES='en,ja' PORT=4001 node server.js",
|
||||||
@@ -147,13 +151,6 @@
|
|||||||
"node": "12 - 14"
|
"node": "12 - 14"
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/github/docs",
|
"repository": "https://github.com/github/docs",
|
||||||
"standard": {
|
|
||||||
"parser": "babel-eslint",
|
|
||||||
"env": [
|
|
||||||
"browser",
|
|
||||||
"jest"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "node script/prevent-translation-commits.js",
|
"pre-commit": "node script/prevent-translation-commits.js",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const files = ['content', 'data'].map(dir => {
|
|||||||
}).flat()
|
}).flat()
|
||||||
|
|
||||||
// match [foo](/v3) and [bar](/v4) Markdown links
|
// match [foo](/v3) and [bar](/v4) Markdown links
|
||||||
const linkRegex = new RegExp('\\(/v[34].*?\\)', 'g')
|
const linkRegex = /\(\/v[34].*?\)/g
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|||||||
@@ -76,11 +76,11 @@ async function main () {
|
|||||||
function getEntry (matches, regex) {
|
function getEntry (matches, regex) {
|
||||||
return matches
|
return matches
|
||||||
? matches.map(match => {
|
? matches.map(match => {
|
||||||
const entry = {}
|
const entry = {}
|
||||||
entry.title = cleanPreviewLinks(match.match(regex)[1])
|
entry.title = cleanPreviewLinks(match.match(regex)[1])
|
||||||
entry.changes = getChangedItems(match.match(regex)[2])
|
entry.changes = getChangedItems(match.match(regex)[2])
|
||||||
return entry
|
return entry
|
||||||
})
|
})
|
||||||
: []
|
: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ allScripts.forEach(script => {
|
|||||||
if (startCommentRegex.test(cmt)) addToReadme = true
|
if (startCommentRegex.test(cmt)) addToReadme = true
|
||||||
if (endCommentRegex.test(cmt)) addToReadme = false
|
if (endCommentRegex.test(cmt)) addToReadme = false
|
||||||
if (addToReadme && !cmt.includes(startComment) && !cmt.includes(endComment)) return cmt
|
if (addToReadme && !cmt.includes(startComment) && !cmt.includes(endComment)) return cmt
|
||||||
|
return false
|
||||||
})
|
})
|
||||||
// remove comment markers and clean up newlines
|
// remove comment markers and clean up newlines
|
||||||
.map(cmt => cmt.replace(/^(\/\/|#) ?/m, ''))
|
.map(cmt => cmt.replace(/^(\/\/|#) ?/m, ''))
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ describe('sidebar', () => {
|
|||||||
|
|
||||||
let $homePage, $githubPage, $enterprisePage
|
let $homePage, $githubPage, $enterprisePage
|
||||||
beforeAll(async (done) => {
|
beforeAll(async (done) => {
|
||||||
;[$homePage, $githubPage, $enterprisePage] = await Promise.all([
|
[$homePage, $githubPage, $enterprisePage] = await Promise.all([
|
||||||
getDOM('/en'),
|
getDOM('/en'),
|
||||||
getDOM('/en/github'),
|
getDOM('/en/github'),
|
||||||
getDOM('/en/enterprise/admin')
|
getDOM('/en/enterprise/admin')
|
||||||
|
|||||||
Reference in New Issue
Block a user