How to config VSCode’s Organize Imports order?

The built-in “Organize Imports” functionality has no configuration, according to the documentation. You can customize import ordering using a third-party extension, such as alfnielsen.vsc-organize-imports or by using a separate linting tool like eslint or tslint. In eslint (my recommendation, since tslint has been deprecated), you’ll need to also use a plugin like eslint-plugin-import to get … Read more

How to install ESlint globally?

You can install Node modules within the project (locally) or globally. To switch to globally, you may use the -g flag, like so: npm install -g eslint Then see if it’s working without Sublime Text (-v flag to see the version of eslint): eslint -v To see where it was installed (assuming MacOS/Linux): which eslint … Read more

Only arrow functions in ESLint?

Anser based on @JohannesEwald comment and @KevinAmiranoff answer. I’m using the following rules: https://www.npmjs.com/package/eslint-plugin-prefer-arrow https://eslint.org/docs/rules/prefer-arrow-callback https://eslint.org/docs/rules/func-style npm install -D eslint-plugin-prefer-arrow .eslintrc or package.json with eslintConfig: “plugins”: [ “prefer-arrow” ], “rules”: { “prefer-arrow/prefer-arrow-functions”: [ “error”, { “disallowPrototype”: true, “singleReturnOnly”: false, “classPropertiesAllowed”: false } ], “prefer-arrow-callback”: [ “error”, { “allowNamedFunctions”: true } ], “func-style”: [ “error”, “expression”, … Read more

Why is @typescript-eslint/parser including files outside of those configured in my tsconfig.json?

Why this happens? I’m not entirely sure, but it seems like @typescript-eslint/parser tries to compare files covered in the eslint configuration (for example by extension) with files included in tsconfig.json. Since the .js files are covered by @typescript-eslint/parser and depending on your eslint configuration, the file is probably included in the eslint run. But because … Read more

How do I configure eslint rules to ignore react-hooks/exhaustive-deps globally? [duplicate]

Usually you don’t want to disable the rule. However, there are few cases where it’s worthwhile to disable it. For example, if you’re doing a fetch on mount and you’re sure it never has to execute again, you can disable it with the code below. // eslint-disable-next-line react-hooks/exhaustive-deps First, confirm the rule is wrong. It … Read more

How to resolve eslint error: “prop spreading is forbidden” in a custom route component?

ES lint discourages the use of prop spreading so that no unwanted/unintended props are being passed to the component. More details here: https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-props-no-spreading.md To disable it for the particular file, you can put: /* eslint-disable react/jsx-props-no-spreading */ at the top line in your component file. For disabling it for all files, try this: Disable in … Read more

tech