Questions tagged [eslint]
The pluggable linting utility for JavaScript and related frameworks.
5,563
questions
0
votes
0
answers
9
views
remove old version of eslint that causes a conflict
When I run npm run watch I get this message Do you want to install 'webpack-cli' (yes/no):
I type y then I get an error indicating a conflict of eslint versions
npm ERR! Found: eslint@4.19.1
npm ...
1
vote
2
answers
41
views
Can I force anonymous default export?
If you have a file named same as default export, why do you need to name this export? I am not DRY there.
We have a rule to prevent the anonymous default export, but how can I do the opposite and ...
-2
votes
0
answers
6
views
How can eslint distinguish dev edit & husky git commit?
when development environment edit code just warnning
but when git commit code will give me wrong
like this:
#.eslintrc.js #
rules: {
// 'no-unused-vars': when git commit trigger husky ? 2: ...
0
votes
1
answer
13
views
propType "onClick" is not required, but has no corresponding defaultProps declaration
I am working on react with typescript [with eslint]. I have a component with certain props among which there are also optional props. For these optional props I am trying to provide default props but ...
0
votes
0
answers
13
views
Is it not recommended to use typescript-eslint/recommended with @angular-eslint/recommended?
I am adding eslint rules to an existing Angular project to ensure developers adhere to a set of "standards". I originally added plugin:@typescript-eslint/recommended, but later switched to ...
0
votes
1
answer
27
views
'Button' cannot be used as a JSX component
These ESLint errors happen with components imported from React Native Paper imports since Expo upgrade from SDK 43 to 45. The project is able to run though.
import { Button } from 'react-native-paper';...
0
votes
0
answers
11
views
Resolve error: webpack with invalid interface loaded as resolver after Expo upgrade to SDK 45
Since upgrading Expo SDK from 43 to 45, I am getting these ESLint errors in every file on the first import line. The project is able to run though.
I've tried adding the eslint-import-resolver-...
0
votes
0
answers
8
views
ESLint plugin CodecptJS Cannot read properties of undefined (reading 'property')
I get the following error while running the eslint command
PS C:\WORK\AutomationPlayground\codeceptjs-boilerplate-project> eslint "**/*.ts" --ignore-pattern node_modules/
Oops! Something ...
0
votes
1
answer
18
views
ESLint - Parse error: Unexpected token semicolon
I get
Parsing error: Unexpected token :
For semicolon after config variable in the constructor
constructor(config: any) {
super(config)
}
And also for this variable declaration
let userData: any
...
1
vote
1
answer
21
views
How to adjust (not 100% override) existing eslint rule's configuration coming from config I extend?
My project's eslint config extends from airbnb:
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.eslint.json",
}...
-1
votes
0
answers
27
views
Find a javascript fix pattern
I have many javascript files, one of which has code with an error and the other without.
How can I find the difference between them in order to find a pattern of fixing for all of them?
For example, ...
0
votes
0
answers
19
views
How to Format code in vs studio with eslint
Initially I used to use prettier to format my React js code. Now I have ESLint integrated with CI that's why my code is throwing minor error of indentation,semiclone and all.Its not possible to go ...
0
votes
0
answers
22
views
Eslint to warn when there is a missing import statement?
I'm using nodejs with regular javascript, and using eslint. My eslint is setup to catch many errors in my code - however it isn't catching when I forgot to import a package into my code. Below is one ...
0
votes
1
answer
31
views
Why is Buffer assignment triggering an unsafe assignment error?
I have a TypeScript project that is leveraging ESLint. I have a class that utilizes a Buffer as a class attribute. I want to be able to set the buffer as part of construction.
example.ts
export ...
0
votes
1
answer
30
views
Is eslint pre-commit hook in CRA bootstrapped application required?
My react application is bootstrapped using CRA(react-scripts v4.0.0) and I want to add a code formatter (prettier to be specific) that must format the code before committing the changes to my git repo....
0
votes
1
answer
28
views
Error with eslint and vue/comment directive
Hello I was just running my website and I have 20 errors like this :
Module Error (from ./node_modules/eslint-loader/dist/cjs.js):
error clear vue/comment-directive
Any idea what is the problem ...
0
votes
0
answers
19
views
How to prevent rule `@angular-eslint/template/i18n` from linting `mat-icon` elements
I use the rule @angular-eslint/template/i18n to lint elements in template that contains text node and doesn't have an i18n attribute.
The Angular Material mat-icon elements use inner text to identify ...
0
votes
0
answers
22
views
Ordering member for async and method in Typescript-ESLint
Is there a way for ordering async / sync method member ?
example
# ❌ Incorrect
function myFunction() {
// something code
}
async function myAsyncFunction() {
// something code
}
# ✅ correct
...
0
votes
0
answers
14
views
How to setup ESLint to format on each new line, in VSCode?
I'm trying to get ESLint to format with the formatOnType option. I know that the usual setup for the settings.json file is
{
"editor.formatOnSave": true,
"editor....
0
votes
0
answers
6
views
how to disable eslint popups in vscode
I don't want to suppress errors, I just want to get rid of this annoying popup that occurs with every one of them. Underlining and showing output errors is fine, but this popup doesn't seem to have a ...
2
votes
1
answer
27
views
TypeScript `extend` produces ESLint error when extending a template string?
I want to implement a type TrimStart like this:
type TrimStart<T extends string> = T extends ` ${infer Rest}` ? TrimStart<Rest> : T;
type TT = TrimStart<' Vue React Angular'>; // '...
0
votes
0
answers
28
views
TypeScript Unsafe Member Access when calling method from a Lerna Module
unsafe member access when calling methods from a module (handled using lerna)
I have a project where a module is created using different typescript components.
Example:
export const localization: {
...
-1
votes
1
answer
24
views
Why is ESLint complaining about "Unnecessary conditional" when checking if an array value exists?
const array = [1,2,3]
if (array[5] === undefined)
array[5] = 5
I'm using Typescript and ESLint and I don't understand why this ESLint error is showing for array[5] === undefined:
Unnecessary ...
0
votes
0
answers
22
views
running eslint on project files
I'm trying to run eslint to fix code formation errors
I downloaded eslint locally on my project
I have eslintrc.js file that contain eslint configuration
when I run npx eslint myfile.js I only get ...
0
votes
1
answer
25
views
.eslintrc file not overriding
I have this rule turned on: "@typescript-eslint/no-unused-vars": "error",
but am attempting to override it
"overrides": [
{
"files": ["...
-1
votes
0
answers
32
views
Parsing error: Cannot use import statement outside a module
script: "lint": "eslint --ext .js,.jsx,.ts,.tsx ./src",
I am getting error Parsing error: Cannot use import statement outside a module
Adding "type": "module"...
0
votes
0
answers
32
views
Is there a way native javasacript way to prevent excessive memory usage without await in loops?
I see that ES Lint is discouraging the use of await in loops, but I don't see any other native-language based option to prevent randomly excessive memory usage when the process inside the loop ...
1
vote
1
answer
48
views
+100
Rules are only applied from the last override?
I have multiple overrides that target different file subsets, but some overlap.
But eslint only seems to use the last matched override, thereby ignoring some of my rules.
I have the following config:
{...
0
votes
2
answers
45
views
When running "ng lint" in a clean Angular project eslint gives errors for a completely different project in another folder
I have a very strange issue with Eslint and Angular. Every time I run ng lint I get errors such as:
An unhandled exception occurred: Cannot read config file: [COMPLETELY_DIFFERENT_PROJECT_PATH]\...
0
votes
0
answers
13
views
ESLint error "'svelte' is not defined" when using svelte.JSX.MouseEventHandler
In a SvelteKit project, I have included the a svelte type. My problem is that my linting (ESLint) throws an error saying that 'svelte' is not defined. My code is as follows:
<script lang="ts&...
0
votes
0
answers
33
views
React: Eslint fix remove prop name={name} from jsx
There's eslint errors when the linter auto fix errors it removes the {name} from name={name}
eslint error that trying to fix : Function component is not a function expressioneslintreact/function-...
1
vote
0
answers
19
views
ESLint disabled rules are disabled in editor but keep showing errors in console/app
I decided to integrate prettier to work together with my eslint, and because of this I have to disable some eslint rules that from what I learned in my researches wont work together with prettier, ...
0
votes
0
answers
16
views
Using @typescript-eslint/parser in browser
Problem
I'm trying to use @typescript-eslint/parser + eslint for linting code in an online editor. Right now I've got the eslint import to work using the officially supported built product for browser....
-1
votes
1
answer
47
views
Eslint not work on vscode when format react code
I'm trying to make ESlint work on my vscode but somehow it does not work,
I install ESlint by these step
Step 1
Install them by yarn add eslint --dev
It perform successful
Step 2
The setup then by ...
-3
votes
2
answers
26
views
eslint for loop 'i' is not defined [duplicate]
I am pretty new to eslint and I am updating my code to fit my eslint file.
module.exports = {
env: {
browser: true,
commonjs: true,
node: true,
es2021: true,
},
extends: 'eslint:...
-1
votes
0
answers
6
views
Wrong ESLint errors
Basically, I don't have much content in my index.ts file but ESLint is returning errors
This is the content of index.ts (the file has an empty line at the end)
export * from './useClickOutside';
0
votes
0
answers
14
views
eslint in vscode doesn't like existing filenames of my yaml files
I have 2 yaml files for Github actions, frontend-build.yaml and backend-build.yaml. After switching from tslint to eslint, The Microsoft eslint extension in vscode has squiggly red lines under all the ...
0
votes
1
answer
15
views
ReactJS - Getting Eslint errors while building or running application
I am creating an application in ReactJS. I have setup react project using "create-react-app". In this project I have added few pages and common layout. Now when I run project using "npm ...
1
vote
1
answer
25
views
Does EsLint have a rule to prefer Object values as key and value?
Looking for a rule(can't seem to find anything, might've just missed it) in EsLint to basically prefer something like this:
const example = {
foo,
bar
};
vs something like this:
const example ...
0
votes
0
answers
10
views
How to break eslint or webpack build if any component has imported data from ./Stories/* folder
We have a React/TS project which bacame too big. In this project we use eslint (airbnb) and StoryBook.
Our components structure is:
/Stories <-- folder for StoryBook
/Helpers <-- getters and ...
4
votes
1
answer
21
views
TypeScript Disallow Unecessary optional chain expression
Is there an es lint rule or typescript config to disallow the following ?
let s: string;
s = 'a';
s?.toLocaleLowerCase();
In my opinion, s is not nullable so no need to do optional chain assertion, ...
0
votes
0
answers
16
views
ESLint print all fixes to terminal
When I run ESLint with the --fix flag, I'd like for the changes made to be output to the terminal. By default it displays no output except for errors or warnings that cannot be fixed, as the ESLint ...
0
votes
0
answers
10
views
Unable to use jsx files in react-native project
Get this issue when using react-native
npx react-native init AwesomeProject
OtherSample.jsx
Error thrown on the device
It works when its renamed from jsx to js is there something that needs to be ...
0
votes
0
answers
13
views
Parcel: Call eslint script on save
I have configured eslint so that when I run npm run lint I get lint errors. How do I configure Parcel so that it runs this command when my code is saved?
0
votes
1
answer
53
views
Why do I get an "Unexpected character '@'" parsing error when I run ESLint?
I'm getting this parsing error (i.e., error Unexpected character '@' ParseError) returned when running eslint --cache --fix. I'm not sure why I'm seeing this error though, since I don't have an '@' ...
0
votes
0
answers
9
views
Can you use custom typescript compiler with @typescript-eslint?
Basically, I have a webpack, package.json, tsconfig.json configs with, but it doesn't lint typescript files, for that you need @typescript-eslint package which can't configure custom compiler, are ...
1
vote
1
answer
35
views
ESLint "no-implicit-globals" rule is being ignored
I'm working with some old Sencha Touch code, written in old-style JavaScript, that I'm trying to clean up. It's too easy with this code to simply misspell a variable and not see the error, because ...
0
votes
1
answer
36
views
How to throw "expressive" / console friendly exceptions in JavaScript?
JavaScript noob here... I'm exploring various options for throwing exceptions.
Throwing a string / primitive value
This seems to be bad practice for several reasons (catching, stacktrace, ...)
Using ...
0
votes
0
answers
28
views
how to configure typescript eslintrc to ignore error?
I want to add
"@typescript-eslint/no-invalid-void-type": [
"error"
]
to my .eslintrc file, and I fixed 50 errors by changing void to undefined but there's one error that ...
0
votes
2
answers
15
views
ESLINT does not get syntax error from HML tag
I'm doing some tests here with ESLINT and I noticed that it doesn't get an error when it's in the HTML tag.
Why does this happen? How to fix?
EXAMPLE?
Property 'h11' does not exist on type 'JSX....