ESLint dollar($) is not defined. (no-undef)

You are missing “env”: { “browser”: true, “commonjs”: true, “es6”: true, “jquery”: true }, $ is not declared as a global without jquery environment enabled. Because of that, you are getting a no-undef error, saying that you are using variable that haven’t been declared.

Understanding the React Hooks ‘exhaustive-deps’ lint rule

The reason the linter rule wants onChange to go into the useEffect hook is because it’s possible for onChange to change between renders, and the lint rule is intended to prevent that sort of “stale data” reference. For example: const MyParentComponent = () => { const onChange = (value) => { console.log(value); } return <MyCustomComponent … Read more

Eslint says all enums in Typescript app are “already declared in the upper scope”

If you are a user of TSLint-to-ESLint this was a bug that has since been fixed so rerunning the script with a newer version would also fix the issue, or just disable the no-shadow and enable @typescript-eslint/no-shadow If you are using some public config that is misusing the rule then be sure to let them … Read more

Global variables in Javascript and ESLint

I don’t think hacking ESLint rules per file is a great idea. You should rather define globals in .eslintrc or package.json. For .eslintrc: “globals”: { “angular”: true } For package.json: “eslintConfig”: { “globals”: { “angular”: true } } Check https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals

Line 0: Parsing error: Cannot read property ‘map’ of undefined

Edit: as noted by Meng-Yuan Huang, this issue no longer occurs in react-scripts@^4.0.1 This error occurs because react-scripts has a direct dependency on the 2.xx range of @typescript-eslint/parser and @typescript-eslint/eslint-plugin. You can fix this by adding a resolutions field to your package.json as follows: “resolutions”: { “**/@typescript-eslint/eslint-plugin”: “^4.1.1”, “**/@typescript-eslint/parser”: “^4.1.1” } NPM users: add the … Read more

How to avoid no-param-reassign when setting a property on a DOM object

As @Mathletics suggests, you can disable the rule entirely by adding this to your .eslintrc.json file: “rules”: { “no-param-reassign”: 0 } Or you can disable the rule specifically for param properties: “rules”: { “no-param-reassign”: [2, { “props”: false }] } Alternatively, you can disable the rule for that function: /* eslint-disable no-param-reassign */ function (el) … Read more

ESLint – Error: Must use import to load ES Module

I think the problem is that you are trying to use the deprecated babel-eslint parser, last updated a year ago, which looks like it doesn’t support ES6 modules. Updating to the latest parser seems to work, at least for simple linting. So, do this: In package.json, update the line “babel-eslint”: “^10.0.2”, to “@babel/eslint-parser”: “^7.5.4”,. This … Read more