Created
July 14, 2024 08:21
-
-
Save dmitry-stepanenko/be9f04633feac978af373458bdca13c8 to your computer and use it in GitHub Desktop.
separate eslint with type checked
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"parser": "@typescript-eslint/parser", | |
"parserOptions": { | |
"project": ["tsconfig.*?.json"], | |
"warnOnUnsupportedTypeScriptVersion": false | |
}, | |
"plugins": ["rxjs", "rxjs-angular"], | |
"overrides": [ | |
{ | |
"files": ["*.ts", "*.tsx"], | |
"rules": { | |
"rxjs/no-unsafe-takeuntil": [ | |
"error", | |
{ | |
"alias": ["untilDestroyed", "takeUntilDestroyed"] | |
} | |
], | |
"rxjs-angular/prefer-takeuntil": [ | |
"error", | |
{ | |
"alias": ["untilDestroyed", "takeUntilDestroyed"], | |
"checkComplete": false, | |
"checkDecorators": ["Component"], | |
"checkDestroy": false | |
} | |
] | |
} | |
}, | |
{ | |
"files": ["*.html"], | |
"extends": ["plugin:@nx/angular-template"], | |
"rules": {} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { execSync } from 'node:child_process'; | |
import yargs from 'yargs'; | |
(function () { | |
const { base, head } = yargs(process.argv).argv; | |
if (!base || !head) { | |
throw new Error('"head" and "base" params are required'); | |
} | |
const deletedFiles = execSync( | |
`git diff ${base} ${head} --name-only --diff-filter=D` | |
) | |
.toString() | |
.split('\n'); | |
const deletedFilesSet = new Set(deletedFiles); | |
const changedFiles = execSync(`git diff ${base} ${head} --name-only`) | |
.toString() | |
.split('\n') | |
// deleted files cannot be linted | |
.filter((f) => f?.endsWith('.ts') && !deletedFilesSet.has(f)); | |
console.log( | |
`Files to be checked (${changedFiles.length} total): `, | |
changedFiles.slice(0, 100) + changedFiles.length > 100 ? '...' : '' | |
); | |
let batches = []; | |
const BATCH_SIZE = 1000; | |
if (changedFiles.length > BATCH_SIZE) { | |
let count = 0; | |
while (count < changedFiles.length) { | |
batches.push(changedFiles.slice(count, count + BATCH_SIZE)); | |
count += BATCH_SIZE; | |
} | |
console.log( | |
`Too many files to check, command will be split in ${batches.length} parts` | |
); | |
} else { | |
batches.push(changedFiles); | |
} | |
for (let index = 0; index < batches.length; index++) { | |
const batch = batches[index]; | |
if (batches.length > 1) { | |
console.log(`Running batch ${index}`); | |
} | |
execSync(`npm run lint:with-type-checker -- ${batch.join(' ')}`, { | |
stdio: [0, 1, 2], | |
}); | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
... | |
'{apps,libs,tools}/**/*.ts': 'npm run lint:with-type-checker --', | |
... | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
"scripts": { | |
... | |
"lint:with-type-checker": "eslint --config .eslintrc-with-type-checker.json" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment