My company has been working to convert all of our JavaScript (.js
or .jsx
) files into TypeScript (.ts
& .tsx
). The problem is, we re a fairly large company and there will be a continuous stream of .js
and .jsx
files sneaking into the codebase unless we lint against them specifically. Also, ideally there would be a way to force a bypass of this for circumstances in which we need .js
or .jsx
files.
We use ESLint, typescript-eslint, and prettier, is there an easy way to set a rule banning plain JavaScript files from being committed? It seems like this should be really easy but I can t find any information on it - all searches seem to turn up results on ignoring certain filetypes, rather than banning them.
I m considering skipping using a linter altogether and running something like
# Prevent committing .js and .jsx files
git diff --cached --name-only | grep -E .jsx?$ > /dev/null
if [[ $? == 0 ]]; then
echo "Error: JavaScript files (.js/.jsx) are not allowed in this repository."
exit 1
in a pre-commit hook, or making an entirely new rule in a custom plugin, and then hooking that up to our repository. In either case I feel like others must have solved this problem by now, is there an easier existing solution?