diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 77bb6c4691..0000000000 --- a/.eslintignore +++ /dev/null @@ -1,20 +0,0 @@ -# NOTE: This file and .prettierignore must contain same paths. - -/.cache -/art -/coverage -/node/lib -/node/src/fbs -/rust -/target -/worker/deps -/worker/fbs -/worker/fuzzer -/worker/include -/worker/prebuild -/worker/pip_invoke -/worker/src -/worker/subprojects -/worker/test -/worker/out -/NO_GIT diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 1a5b7522c6..0000000000 --- a/.prettierignore +++ /dev/null @@ -1,20 +0,0 @@ -# NOTE: This file and .eslintignore must contain same paths. - -/.cache -/art -/coverage -/node/lib -/node/src/fbs -/rust -/target -/worker/deps -/worker/fbs -/worker/fuzzer -/worker/include -/worker/prebuild -/worker/pip_invoke -/worker/src -/worker/subprojects -/worker/test -/worker/out -/NO_GIT diff --git a/npm-scripts.mjs b/npm-scripts.mjs index 280f68c270..a849f65a23 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -25,6 +25,28 @@ const WORKER_PREBUILD_TAR_PATH = `${WORKER_PREBUILD_DIR}/${WORKER_PREBUILD_TAR}` const GH_OWNER = 'versatica'; const GH_REPO = 'mediasoup'; +// Paths for ESLint to check. Converted to string for convenience. +const ESLINT_PATHS = ['node/src', 'npm-scripts.mjs', 'worker/scripts'].join( + ' ' +); +// Paths for ESLint to ignore. Converted to string argument for convenience. +const ESLINT_IGNORE_PATTERN_ARGS = ['node/src/fbs'] + .map(entry => `--ignore-pattern ${entry}`) + .join(' '); +// Paths for Prettier to check/write. Converted to string for convenience. +// NOTE: Prettier ignores paths in .gitignore so we don't need to care about +// node/src/fbs. +const PRETTIER_PATHS = [ + 'CHANGELOG.md', + 'CONTRIBUTING.md', + 'README.md', + 'doc', + 'node/src', + 'npm-scripts.mjs', + 'package.json', + 'worker/scripts', +].join(' '); + const task = process.argv[2]; const args = process.argv.slice(3).join(' '); @@ -331,13 +353,15 @@ function cleanWorkerArtifacts() { function lintNode() { logInfo('lintNode()'); - executeCmd('prettier . --check'); - // Ensure there are no rules that are unnecessary or conflict with Prettier // rules. executeCmd('eslint-config-prettier .eslintrc.js'); - executeCmd('eslint -c .eslintrc.js --max-warnings 0 .'); + executeCmd( + `eslint -c .eslintrc.js --ext=ts,js,mjs --max-warnings 0 ${ESLINT_IGNORE_PATTERN_ARGS} ${ESLINT_PATHS}` + ); + + executeCmd(`prettier --check ${PRETTIER_PATHS}`); } function lintWorker() { @@ -351,7 +375,7 @@ function lintWorker() { function formatNode() { logInfo('formatNode()'); - executeCmd('prettier . --write'); + executeCmd(`prettier --write ${PRETTIER_PATHS}`); } function flatcNode() {