Skip to content

Commit

Permalink
Get rid of .eslintignore and .prettierignore
Browse files Browse the repository at this point in the history
### Details

- Instead of ignoring complex paths, be explicit in what ESLint and Prettier must check.
  • Loading branch information
ibc committed May 9, 2024
1 parent f197389 commit 031faa8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 44 deletions.
20 changes: 0 additions & 20 deletions .eslintignore

This file was deleted.

20 changes: 0 additions & 20 deletions .prettierignore

This file was deleted.

32 changes: 28 additions & 4 deletions npm-scripts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ');

Expand Down Expand Up @@ -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() {
Expand All @@ -351,7 +375,7 @@ function lintWorker() {
function formatNode() {
logInfo('formatNode()');

executeCmd('prettier . --write');
executeCmd(`prettier --write ${PRETTIER_PATHS}`);
}

function flatcNode() {
Expand Down

0 comments on commit 031faa8

Please sign in to comment.