Add glossaries to lint-files tests (#17481)
* Add glossariesDir to glob * Actually make the test work * Fix the (legitimate) failures
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
- term: bio
|
- term: bio
|
||||||
description: >-
|
description: >-
|
||||||
The user-generated description found on a profile:
|
The user-generated description found on a profile:
|
||||||
https://help.github.com/articles/adding-a-bio-to-your-profile/
|
[Adding a bio to your profile](/articles/adding-a-bio-to-your-profile)
|
||||||
- term: billing cycle
|
- term: billing cycle
|
||||||
description: The interval of time for your specific billing plan.
|
description: The interval of time for your specific billing plan.
|
||||||
- term: billing email
|
- term: billing email
|
||||||
@@ -160,8 +160,8 @@
|
|||||||
- term: contributions
|
- term: contributions
|
||||||
description: >-
|
description: >-
|
||||||
Specific activities on GitHub that will:
|
Specific activities on GitHub that will:
|
||||||
- Add a square to a user's contribution graph: "[What counts as a contribution](https://help.github.com/articles/viewing-contributions-on-your-profile/#what-counts-as-a-contribution)"
|
- Add a square to a user's contribution graph: "[What counts as a contribution](/articles/viewing-contributions-on-your-profile/#what-counts-as-a-contribution)"
|
||||||
- Add activities to a user's timeline on their profile: "[Contribution activity](https://help.github.com/articles/viewing-contributions-on-your-profile/#contribution-activity)"
|
- Add activities to a user's timeline on their profile: "[Contribution activity](/articles/viewing-contributions-on-your-profile/#contribution-activity)"
|
||||||
- term: contributor
|
- term: contributor
|
||||||
description: >-
|
description: >-
|
||||||
A contributor is someone who does not have collaborator access to a repository but has contributed to a project and had a pull request they opened merged into the repository.
|
A contributor is someone who does not have collaborator access to a repository but has contributed to a project and had a pull request they opened merged into the repository.
|
||||||
@@ -230,7 +230,7 @@
|
|||||||
description: >-
|
description: >-
|
||||||
A branch used to experiment with a new feature or fix an issue that is not in production. Also called a topic branch.
|
A branch used to experiment with a new feature or fix an issue that is not in production. Also called a topic branch.
|
||||||
- term: fenced code block
|
- term: fenced code block
|
||||||
description: An indented block of code you can create with GitHub Flavored Markdown using triple backticks \`\`\` before and after the code block. See this [example](https://help.github.com/en/articles/creating-and-highlighting-code-blocks#fenced-code-blocks).
|
description: An indented block of code you can create with GitHub Flavored Markdown using triple backticks \`\`\` before and after the code block. See this [example](/articles/creating-and-highlighting-code-blocks#fenced-code-blocks).
|
||||||
- term: fetch
|
- term: fetch
|
||||||
description: >-
|
description: >-
|
||||||
When you use `git fetch`, you're adding changes from the remote repository to
|
When you use `git fetch`, you're adding changes from the remote repository to
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const rootDir = path.join(__dirname, '../..')
|
|||||||
const contentDir = path.join(rootDir, 'content')
|
const contentDir = path.join(rootDir, 'content')
|
||||||
const reusablesDir = path.join(rootDir, 'data/reusables')
|
const reusablesDir = path.join(rootDir, 'data/reusables')
|
||||||
const variablesDir = path.join(rootDir, 'data/variables')
|
const variablesDir = path.join(rootDir, 'data/variables')
|
||||||
|
const glossariesDir = path.join(rootDir, 'data/glossaries')
|
||||||
|
|
||||||
const languageCodes = Object.keys(languages)
|
const languageCodes = Object.keys(languages)
|
||||||
|
|
||||||
@@ -320,7 +321,19 @@ describe('lint-files', () => {
|
|||||||
const variableYamlRelPaths = variableYamlAbsPaths.map(p => slash(path.relative(rootDir, p)))
|
const variableYamlRelPaths = variableYamlAbsPaths.map(p => slash(path.relative(rootDir, p)))
|
||||||
const variableYamlTuples = zip(variableYamlRelPaths, variableYamlAbsPaths)
|
const variableYamlTuples = zip(variableYamlRelPaths, variableYamlAbsPaths)
|
||||||
|
|
||||||
describe.each(variableYamlTuples)(
|
const glossariesYamlAbsPaths = walk(glossariesDir, yamlWalkOptions).sort()
|
||||||
|
const glossariesYamlRelPaths = glossariesYamlAbsPaths.map(p => slash(path.relative(rootDir, p)))
|
||||||
|
const glossariesYamlTuples = zip(glossariesYamlRelPaths, glossariesYamlAbsPaths)
|
||||||
|
|
||||||
|
// Returns `content` if its a string, or `content.description` if it can.
|
||||||
|
// Used for getting the nested `description` key in glossary files.
|
||||||
|
function getContent (content) {
|
||||||
|
if (typeof content === 'string') return content
|
||||||
|
if (typeof content.description === 'string') return content.description
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
describe.each([...variableYamlTuples, ...glossariesYamlTuples])(
|
||||||
'in "%s"',
|
'in "%s"',
|
||||||
(yamlRelPath, yamlAbsPath) => {
|
(yamlRelPath, yamlAbsPath) => {
|
||||||
let dictionary, isEarlyAccess
|
let dictionary, isEarlyAccess
|
||||||
@@ -336,8 +349,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(relativeArticleLinkRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(relativeArticleLinkRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
@@ -351,8 +365,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(languageLinkRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(languageLinkRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
@@ -366,8 +381,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(versionLinkRegEx) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(versionLinkRegEx) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
@@ -381,8 +397,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(domainLinkRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(domainLinkRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
@@ -398,8 +415,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(earlyAccessLinkRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(earlyAccessLinkRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
@@ -416,8 +434,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(earlyAccessImageRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(earlyAccessImageRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
@@ -434,8 +453,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(badEarlyAccessImageRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(badEarlyAccessImageRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
@@ -449,8 +469,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(oldVariableRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(oldVariableRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => {
|
matches.push(...valMatches.map((match) => {
|
||||||
const example = match
|
const example = match
|
||||||
@@ -468,8 +489,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(oldOcticonRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(oldOcticonRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
@@ -483,8 +505,9 @@ describe('lint-files', () => {
|
|||||||
const matches = []
|
const matches = []
|
||||||
|
|
||||||
for (const [key, content] of Object.entries(dictionary)) {
|
for (const [key, content] of Object.entries(dictionary)) {
|
||||||
if (typeof content !== 'string') continue
|
const contentStr = getContent(content)
|
||||||
const valMatches = (content.match(oldExtendedMarkdownRegex) || [])
|
if (!contentStr) continue
|
||||||
|
const valMatches = (contentStr.match(oldExtendedMarkdownRegex) || [])
|
||||||
if (valMatches.length > 0) {
|
if (valMatches.length > 0) {
|
||||||
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
matches.push(...valMatches.map((match) => `Key "${key}": ${match}`))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user