devops: validate js code snippets in flint (#34580)
This commit is contained in:
parent
a1451c75f8
commit
cd7f3b6e65
|
@ -37,7 +37,7 @@
|
||||||
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && node utils/generate_channels.js && node utils/generate_types/ && npm run lint-tests && npm run test-types && npm run lint-packages",
|
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && node utils/generate_channels.js && node utils/generate_types/ && npm run lint-tests && npm run test-types && npm run lint-packages",
|
||||||
"lint-packages": "node utils/workspace.js --ensure-consistent",
|
"lint-packages": "node utils/workspace.js --ensure-consistent",
|
||||||
"lint-tests": "node utils/lint_tests.js",
|
"lint-tests": "node utils/lint_tests.js",
|
||||||
"flint": "concurrently \"npm run eslint\" \"npm run tsc\" \"npm run doc\" \"npm run check-deps\" \"node utils/generate_channels.js\" \"node utils/generate_types/\" \"npm run lint-tests\" \"npm run test-types\" \"npm run lint-packages\"",
|
"flint": "concurrently \"npm run eslint\" \"npm run tsc\" \"npm run doc\" \"npm run check-deps\" \"node utils/generate_channels.js\" \"node utils/generate_types/\" \"npm run lint-tests\" \"npm run test-types\" \"npm run lint-packages\" \"node utils/doclint/linting-code-snippets/cli.js --js-only\"",
|
||||||
"clean": "node utils/build/clean.js",
|
"clean": "node utils/build/clean.js",
|
||||||
"build": "node utils/build/build.js",
|
"build": "node utils/build/build.js",
|
||||||
"watch": "node utils/build/build.js --watch --lint",
|
"watch": "node utils/build/build.js --watch --lint",
|
||||||
|
|
|
@ -44,8 +44,9 @@ function getAllMarkdownFiles(dirPath, filePaths = []) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
|
const jsOnly = process.argv.includes('--js-only');
|
||||||
|
const lintingServiceFactory = new LintingServiceFactory(jsOnly);
|
||||||
const documentationRoot = path.join(PROJECT_DIR, 'docs', 'src');
|
const documentationRoot = path.join(PROJECT_DIR, 'docs', 'src');
|
||||||
const lintingServiceFactory = new LintingServiceFactory();
|
|
||||||
let documentation = parseApi(path.join(documentationRoot, 'api'));
|
let documentation = parseApi(path.join(documentationRoot, 'api'));
|
||||||
|
|
||||||
/** @type {CodeSnippet[]} */
|
/** @type {CodeSnippet[]} */
|
||||||
|
@ -69,6 +70,8 @@ const run = async () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await lintingServiceFactory.lintAndReport(codeSnippets);
|
await lintingServiceFactory.lintAndReport(codeSnippets);
|
||||||
|
if (jsOnly)
|
||||||
|
return;
|
||||||
const { hasErrors } = lintingServiceFactory.reportMetrics();
|
const { hasErrors } = lintingServiceFactory.reportMetrics();
|
||||||
if (hasErrors)
|
if (hasErrors)
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
@ -222,12 +225,12 @@ class JavaLintingService extends LintingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
class LintingServiceFactory {
|
class LintingServiceFactory {
|
||||||
constructor() {
|
constructor(jsOnly) {
|
||||||
/** @type {LintingService[]} */
|
/** @type {LintingService[]} */
|
||||||
this.services = [
|
this.services = [
|
||||||
new JSLintingService(),
|
new JSLintingService(),
|
||||||
]
|
]
|
||||||
if (!process.env.NO_EXTERNAL_DEPS) {
|
if (!jsOnly) {
|
||||||
this.services.push(
|
this.services.push(
|
||||||
new PythonLintingService(),
|
new PythonLintingService(),
|
||||||
new CSharpLintingService(),
|
new CSharpLintingService(),
|
||||||
|
|
Loading…
Reference in New Issue