ESLint – ‘process’ is not defined

When I got error I had “browser”: true instead of “node”: true. I have fixed this with following config for .eslintrc.json file- { “env”: { “node”: true, “commonjs”: true }, “extends”: “eslint:recommended”, “rules”: { “indent”: [ “error”, “tab” ], “linebreak-style”: [ “error”, “unix” ], “quotes”: [ “error”, “single” ], “semi”: [ “error”, “always” ] }, … Read more

React eslint error missing in props validation

You need to define propTypes as a static getter if you want it inside the class declaration: static get propTypes() { return { children: PropTypes.any, onClickOut: PropTypes.func }; } If you want to define it as an object, you need to define it outside the class, like this: IxClickOut.propTypes = { children: PropTypes.any, onClickOut: PropTypes.func, … Read more

What’s the difference between prettier-eslint, eslint-plugin-prettier and eslint-config-prettier?

tl;dr: Use eslint-config-prettier, you can ignore the rest. ESLint contains many rules and those that are formatting-related might conflict with Prettier, such as arrow-parens, space-before-function-paren, etc. Hence using them together will cause some issues. The following tools have been created to use ESLint and Prettier together. prettier-eslint eslint-plugin-prettier eslint-config-prettier What it is A JavaScript module … Read more

How to disable multiple rules for eslint nextline

If you want to disable multiple ESLint errors, you can do the following (note the commas): For the next line: // eslint-disable-next-line no-return-assign, no-param-reassign ( your code… ) For this line: ( your code… ) // eslint-disable-line no-return-assign, no-param-reassign Or alternatively for an entire code block (note that this only works with multi-line comment syntax): … Read more

ESLint Unexpected use of isNaN

As the documentation suggests, use Number.isNaN. const isNumber = value => !Number.isNaN(Number(value)); Quoting Airbnb’s documentation: Why? The global isNaN coerces non-numbers to numbers, returning true for anything that coerces to NaN. If this behavior is desired, make it explicit. // bad isNaN(‘1.2’); // false isNaN(‘1.2.3’); // true // good Number.isNaN(‘1.2.3’); // false Number.isNaN(Number(‘1.2.3’)); // true