Create a list of known code languages (#37648)

This commit is contained in:
Kevin Heis 2023-06-08 10:44:56 -07:00 коммит произвёл GitHub
Родитель 52937ae5ca
Коммит c0adfdee27
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 100 добавлений и 0 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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)
}
})
})