Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

devops: validate js code snippets in flint (#34580)

Yury Semikhatskycd7f3b6e65d2
diff --git a/package.json b/package.json
index 2b138262eb..04795972f3 100644
--- a/package.json
+++ b/package.json
@@ -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-packages": "node utils/workspace.js --ensure-consistent",
"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",
"build": "node utils/build/build.js",
"watch": "node utils/build/build.js --watch --lint",
diff --git a/utils/doclint/linting-code-snippets/cli.js b/utils/doclint/linting-code-snippets/cli.js
index 7139bb105a..f704087032 100644
--- a/utils/doclint/linting-code-snippets/cli.js
+++ b/utils/doclint/linting-code-snippets/cli.js
@@ -44,8 +44,9 @@ function getAllMarkdownFiles(dirPath, filePaths = []) {
}
const run = async () => {
+ const jsOnly = process.argv.includes('--js-only');
+ const lintingServiceFactory = new LintingServiceFactory(jsOnly);
const documentationRoot = path.join(PROJECT_DIR, 'docs', 'src');
- const lintingServiceFactory = new LintingServiceFactory();
let documentation = parseApi(path.join(documentationRoot, 'api'));
/** @type {CodeSnippet[]} */
@@ -69,6 +70,8 @@ const run = async () => {
});
}
await lintingServiceFactory.lintAndReport(codeSnippets);
+ if (jsOnly)
+ return;
const { hasErrors } = lintingServiceFactory.reportMetrics();
if (hasErrors)
process.exit(1);
@@ -222,12 +225,12 @@ class JavaLintingService extends LintingService {
}
class LintingServiceFactory {
- constructor() {
+ constructor(jsOnly) {
/** @type {LintingService[]} */
this.services = [
new JSLintingService(),
]
- if (!process.env.NO_EXTERNAL_DEPS) {
+ if (!jsOnly) {
this.services.push(
new PythonLintingService(),
new CSharpLintingService(),