I have react-native code. I install ESLint. I use it but its show error. While I use single quotes it show me error Replace ‘react-native’ with “react-native” eslint(prettier/prettier) And when I use double qoutes it show me another error String must use singlequote. eslint(quotes) her…
Tag: eslint
Eslint: how to handle no-use-before-define for dependent functions?
I have 2 dependent functions that call each others, so one or the other has to be declared first which fires an eslint no-use-before-define error. I know I can disable the rule but is there any better way do do this? Simplified example: I can’t merge a and b as they both need to be called separately som…
How to avoid the ‘no-param-reassign’ rule with a input’s handleChange?
I’m working to build a React Textarea that auto grows/shrinks as the user types. I’ve built my component inspired by this codepen: https://codepen.io/Libor_G/pen/eyzwOx While I have this working nicely, I’m getting an es-lint error I’m unsure how to correctly resolve. eslint is not lik…
Eslint glob (**) is not considering all directories recursively
I am using OSX, in my package.json file I have the script entry: “lint”: “eslint ./src/**/*.js” However, when I run npm lint only the 1st level of directories are being considered for linting, eg. ./src/dir/* not ./src/dir/nested_dir/*. I was under the impression that ** glob indicated…
Cannot fix eslint rule on indenting case statements in switch statement
Here is a screenshot of my sublime text window showing the eslint error being thrown for the switch / case statement. I want to have to indent 4 spaces, as the code shows. and here are 4 different attempts to try to allow for an indent of 4 spaces, via modifications in the .eslintrc file in my react app. I
How to add a keyboard listener to my onClick handler?
I have the following: My CSS: I need this because I need the textarea’s placeholder are to be horizontally and vertically centered in the page. Given textareas can’t vertically center text, I need to keep the height of the textarea short. I therefore need to make it so when the user clicks outside…
Build error while compiling create-react-app
I am new to Reactjs and am started learning it. I have been trying to start a basic hello world program but its failing at compilation level. Created a start up hello-word program with create-react-app hello-world it gave me a nice folder structure with bunch of files. And Here you can see the compilation err…
How can I use ESLint no-unused-vars for a block of code?
I need to disable some variable checks in ESLint. Currently, I am using this code, but am not getting the desired result: Two questions: Is there a variant which can enable no-unused-vars for a block of code? Something like… Or could I make Hey a global variable so that it can be ignored everywhere? Ans…
How to remove ESlint error no-unresolved from importing ‘react’
no-unresolved https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md After installing eslint-import-resolver-webpack My .eslintrc config My package.json Webpack Answer You can add an option to ignore case: This thread at github also describes how the linter was checking case…
How to configure eslint indent for WebStorm?
How to set “indent” in .eslintr.json to match the default used in WebStorm? Everything I’ve tried so far, as per the official documentation can’t match it: “indent”: [“error”, 2] – gives many Expected indentation of 2 spaces but found 4 “indent”…