mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore: land failing renovate updates (#67035)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
32c65547ac
commit
39408b3c83
@@ -31,14 +31,17 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@freecodecamp/eslint-config": "workspace:*",
|
||||
"@types/js-yaml": "4.0.5",
|
||||
"@types/js-yaml": "4.0.9",
|
||||
"@types/yargs": "17.0.35",
|
||||
"@vitest/ui": "3.2.4",
|
||||
"eslint": "9.39.1",
|
||||
"markdownlint": "0.33.0",
|
||||
"markdownlint": "0.40.0",
|
||||
"prismjs": "1.30.0",
|
||||
"typescript": "5.9.3",
|
||||
"vitest": "3.2.4",
|
||||
"yargs": "17.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"markdown-it": "^14.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ interface LintResults {
|
||||
[key: string]: unknown[];
|
||||
}
|
||||
|
||||
const configure = (configPath: string) => {
|
||||
const configure = (
|
||||
configPath: string
|
||||
): { lint: (files: string[]) => Promise<LintResults> } => {
|
||||
const lintRules = readFileSync(configPath, 'utf8');
|
||||
const lint = linter(YAML.load(lintRules));
|
||||
|
||||
|
||||
@@ -4,18 +4,15 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { configure, processLintErrors } from './index.js';
|
||||
|
||||
const badYMLError = {
|
||||
const badYMLError = expect.objectContaining({
|
||||
errorContext: '```yml',
|
||||
errorDetail: `bad indentation of a mapping entry at line 3, column 17:
|
||||
testString: testString
|
||||
^`,
|
||||
errorRange: null,
|
||||
fixInfo: null,
|
||||
errorDetail: expect.stringContaining(
|
||||
'bad indentation of a mapping entry at line 3, column 17'
|
||||
),
|
||||
lineNumber: 19,
|
||||
ruleDescription: 'YAML code blocks should be valid',
|
||||
ruleInformation: null,
|
||||
ruleNames: ['yaml-linter']
|
||||
};
|
||||
});
|
||||
|
||||
describe('markdown linter', () => {
|
||||
const good = path.join(__dirname, './fixtures/good.md');
|
||||
@@ -51,6 +48,6 @@ describe('markdown linter', () => {
|
||||
const errors = processLintErrors(results);
|
||||
|
||||
expect(errors[0].file).toContain('badYML.md');
|
||||
expect(errors[0].errors).toContainEqual(badYMLError);
|
||||
expect(errors[0].errors).toEqual(expect.arrayContaining([badYMLError]));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export const names = ['closed-code-blocks'];
|
||||
export const description = 'Code blocks must have closing triple backticks';
|
||||
export const tags = ['code'];
|
||||
export const parser = 'micromark';
|
||||
function rule(params, onError) {
|
||||
params.parsers.micromark.tokens
|
||||
.filter(token => token.type === 'codeFenced')
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import markdownlint from 'markdownlint';
|
||||
import { lint as markdownlint } from 'markdownlint/promise';
|
||||
|
||||
import * as lintPrism from './markdown-prism.js';
|
||||
import * as lintYAML from './markdown-yaml.js';
|
||||
import * as fencedCodeBlock from './fenced-code-block.js';
|
||||
|
||||
const markdownItFactory = () =>
|
||||
import('markdown-it').then(module => module.default({ html: true }));
|
||||
|
||||
export function linter(rules) {
|
||||
const lint = async files => {
|
||||
const options = {
|
||||
files,
|
||||
config: rules,
|
||||
customRules: [lintYAML, lintPrism, fencedCodeBlock]
|
||||
customRules: [lintYAML, lintPrism, fencedCodeBlock],
|
||||
markdownItFactory
|
||||
};
|
||||
|
||||
return await markdownlint.promises.markdownlint(options);
|
||||
return await markdownlint(options);
|
||||
};
|
||||
return lint;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,9 @@ export const names = ['prism-langs'];
|
||||
export const description =
|
||||
'Code block languages should be supported by PrismJS';
|
||||
export const tags = ['prism'];
|
||||
export const parser = 'markdownit';
|
||||
function rule(params, onError) {
|
||||
params.tokens
|
||||
params.parsers.markdownit.tokens
|
||||
.filter(param => param.type === 'fence')
|
||||
.forEach(codeBlock => {
|
||||
// whitespace around the language is ignored by the parser, as is case:
|
||||
|
||||
@@ -3,8 +3,9 @@ import jsYaml from 'js-yaml';
|
||||
export const names = ['yaml-linter'];
|
||||
export const description = 'YAML code blocks should be valid';
|
||||
export const tags = ['yaml'];
|
||||
export const parser = 'markdownit';
|
||||
function rule(params, onError) {
|
||||
params.tokens
|
||||
params.parsers.markdownit.tokens
|
||||
.filter(param => param.type === 'fence')
|
||||
.filter(param => param.info === 'yml' || param.info === 'yaml')
|
||||
// TODO since the parser only looks for yml, should we reject yaml blocks?
|
||||
|
||||
Reference in New Issue
Block a user