зеркало из https://github.com/github/docs.git
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:
Родитель
4d4649512f
Коммит
b6de7c6887
|
@ -0,0 +1 @@
|
|||
dist/
|
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 => {
|
||||
|
@ -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 => {
|
||||
|
|
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -194,5 +194,6 @@ function getChildArticles (tocItems, maptopicPath) {
|
|||
} else {
|
||||
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
|
||||
;[pages, site, earlyAccessPaths] = await Promise.all([
|
||||
[pages, site, earlyAccessPaths] = await Promise.all([
|
||||
require('./pages')(),
|
||||
require('./site-data')(),
|
||||
fetchEarlyAccessPaths()
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
17
package.json
17
package.json
|
@ -91,6 +91,11 @@
|
|||
"del": "^4.1.1",
|
||||
"dependency-check": "^4.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",
|
||||
"graphql": "^14.5.8",
|
||||
"heroku-client": "^3.1.0",
|
||||
|
@ -116,7 +121,6 @@
|
|||
"replace": "^1.2.0",
|
||||
"revalidator": "^0.3.1",
|
||||
"robots-parser": "^2.1.1",
|
||||
"standard": "^14.3.1",
|
||||
"start-server-and-test": "^1.11.3",
|
||||
"supertest": "^4.0.2",
|
||||
"webpack-dev-middleware": "^3.7.2",
|
||||
|
@ -127,8 +131,8 @@
|
|||
"dev": "npm start",
|
||||
"build": "cross-env NODE_ENV=production npx webpack --mode production",
|
||||
"start-all-languages": "cross-env NODE_ENV=development nodemon server.js",
|
||||
"lint": "standard --fix && prettier -w \"**/*.{yml,yaml}\"",
|
||||
"test": "jest && standard && prettier -c \"**/*.{yml,yaml}\" && npm run check-deps",
|
||||
"lint": "eslint --fix . && prettier -w \"**/*.{yml,yaml}\"",
|
||||
"test": "jest && eslint . && prettier -c \"**/*.{yml,yaml}\" && npm run check-deps",
|
||||
"prebrowser-test": "npm run build",
|
||||
"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",
|
||||
|
@ -147,13 +151,6 @@
|
|||
"node": "12 - 14"
|
||||
},
|
||||
"repository": "https://github.com/github/docs",
|
||||
"standard": {
|
||||
"parser": "babel-eslint",
|
||||
"env": [
|
||||
"browser",
|
||||
"jest"
|
||||
]
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "node script/prevent-translation-commits.js",
|
||||
|
|
|
@ -16,7 +16,7 @@ const files = ['content', 'data'].map(dir => {
|
|||
}).flat()
|
||||
|
||||
// match [foo](/v3) and [bar](/v4) Markdown links
|
||||
const linkRegex = new RegExp('\\(/v[34].*?\\)', 'g')
|
||||
const linkRegex = /\(\/v[34].*?\)/g
|
||||
|
||||
main()
|
||||
|
||||
|
|
|
@ -76,11 +76,11 @@ async function main () {
|
|||
function getEntry (matches, regex) {
|
||||
return matches
|
||||
? matches.map(match => {
|
||||
const entry = {}
|
||||
entry.title = cleanPreviewLinks(match.match(regex)[1])
|
||||
entry.changes = getChangedItems(match.match(regex)[2])
|
||||
return entry
|
||||
})
|
||||
const entry = {}
|
||||
entry.title = cleanPreviewLinks(match.match(regex)[1])
|
||||
entry.changes = getChangedItems(match.match(regex)[2])
|
||||
return entry
|
||||
})
|
||||
: []
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ allScripts.forEach(script => {
|
|||
if (startCommentRegex.test(cmt)) addToReadme = true
|
||||
if (endCommentRegex.test(cmt)) addToReadme = false
|
||||
if (addToReadme && !cmt.includes(startComment) && !cmt.includes(endComment)) return cmt
|
||||
return false
|
||||
})
|
||||
// remove comment markers and clean up newlines
|
||||
.map(cmt => cmt.replace(/^(\/\/|#) ?/m, ''))
|
||||
|
|
|
@ -6,7 +6,7 @@ describe('sidebar', () => {
|
|||
|
||||
let $homePage, $githubPage, $enterprisePage
|
||||
beforeAll(async (done) => {
|
||||
;[$homePage, $githubPage, $enterprisePage] = await Promise.all([
|
||||
[$homePage, $githubPage, $enterprisePage] = await Promise.all([
|
||||
getDOM('/en'),
|
||||
getDOM('/en/github'),
|
||||
getDOM('/en/enterprise/admin')
|
||||
|
|
Загрузка…
Ссылка в новой задаче