I have my .eslintrc.js as such:
module.exports = {
root: true,
parser: "@babel/eslint-parser",
parserOptions: {
requireConfigFile: false,
babelOptions: {
presets: ["@babel/preset-react"],
},
},
plugins: ["react", "react-hooks"],
rules: {
"no-console": "off",
"react-hooks/exhaustive-deps": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "off",
"@no-restricted-globals": "off",
},
overrides: [
{
files: ["**/*.ts", "**/*.tsx"],
env: { browser: true, es6: true, node: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: { jsx: true },
ecmaVersion: 2018,
sourceType: "module",
project: "./tsconfig.json",
},
plugins: ["@typescript-eslint"],
rules: {
"no-console": "off",
"react-hooks/exhaustive-deps": "off",
"no-unused-vars": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@no-restricted-globals": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
},
},
],
};
This works fine where it throws error finely for ts and tsx files. But after setting this up, my eslint doesn't throw any error for js and jsx files anymore. How can I set it up so that it throws error for both accordingly and properly?
I decided to use the same parser for both my Javascript and Typescript files. My configuration now looks something like this:
I'm not entirely sure this is the best practice but this works for now. If anyone has any input on this, feel free to leave a comment so I can improve my
.eslintrc.js