diff --git a/data/variables/code-languages.yml b/data/variables/code-languages.yml new file mode 100644 index 0000000000..66a2832f43 --- /dev/null +++ b/data/variables/code-languages.yml @@ -0,0 +1,82 @@ +# Comment options: number (#), slash (//), percent (%%), xml (), none +bash: + name: Bash + comment: number +csharp: + name: C# + comment: slash +dockerfile: + name: Dockerfile + comment: number +geojson: + name: GeoJSON + comment: none +golang: + name: Go + comment: slash +graphql: + name: GraphQL + comment: number +groovy: + name: Groovy + comment: slash +html: + name: HTML + comment: xml +http: + name: HTTP + comment: none +java: + name: Java + comment: slash +javascript: + name: JavaScript + comment: slash +json: + name: JSON + comment: none +jsonc: + name: JSONC + comment: slash +markdown: + name: Markdown + comment: xml +math: + name: Math + comment: percent +mermaid: + name: Mermaid + comment: percent +powershell: + name: PowerShell + comment: number +python: + name: Python + comment: number +ruby: + name: Ruby + comment: number +scss: + name: SCSS + comment: slash +shell: + name: Shell + comment: number +stl: + name: STL + comment: none +tasklist: + name: Tasklist + comment: xml +text: + name: Text + comment: number +topojson: + name: TopoJSON + comment: none +xml: + name: XML + comment: xml +yaml: + name: YAML + comment: number diff --git a/src/content-linter/tests/lint-code-languages.js b/src/content-linter/tests/lint-code-languages.js new file mode 100644 index 0000000000..182c6a4615 --- /dev/null +++ b/src/content-linter/tests/lint-code-languages.js @@ -0,0 +1,18 @@ +// Code languages must be listed in data/variables/code-languages.yml +import fs from 'fs' +import walkFiles from '../../../script/helpers/walk-files.js' +import yaml from 'js-yaml' + +const allFiles = walkFiles('content', '.md').concat(walkFiles('data', '.md')) +const languages = Object.keys( + yaml.load(fs.readFileSync('./data/variables/code-languages.yml', 'utf8')) +) + +describe.skip('lint-code-languages', () => { + test.each(allFiles)('%s', async (file) => { + const fileContents = await fs.promises.readFile(file, 'utf8') + for (const [, lang] of fileContents.matchAll(/```(\S+)/gm)) { + expect(languages).toContain(lang) + } + }) +})