Questions tagged [eslint]
The pluggable linting utility for JavaScript and related frameworks.
6,730
questions
0
votes
0
answers
9
views
Unknown option: .module. in Babel and ESLint setup
I'm encountering an issue with my Babel and ESLint setup in a React project. When I run ESLint, I get the following error:
Line 0: Parsing error: Unknown option: .module. Check out https://babeljs.io/...
0
votes
3
answers
55
views
ESLint rule to detect uncalled functions
I have a Logger class which beautifies the logs before showing them in JS browser console. I use .bind() to let console display correct script name and line (like script_name.ts:62) in the sources ...
0
votes
2
answers
21
views
Cannot longer deploy my firebase functions
I have a lot of error when trying to reply my fibres functions.
Looks like it is related to lint.
$ npm run deploy
> deploy
> firebase deploy --only functions
=== Deploying to 'shokaze-8cbe9'.....
0
votes
1
answer
30
views
TypeScript PrimeReact async Button onClick handler ESLint error
I try to export data from DataTable in PrimeReact. The Button onClick doesn't allow async callback as eslint told. How can I call this function properly?
const exportCSV = useCallback(async (...
1
vote
0
answers
14
views
Using eslint boolean prop naming rule on typescript interfaces
I have set up eslint with a rule react/boolean-prop-naming to flag boolean props that aren't named with 'is', 'has' etc. I can only get it to work on typescript component props when props are defined ...
0
votes
1
answer
14
views
throws an error while running my custom rules in ESlint 1:1 error Definition for rule 'D:/Sports/eslint-rules/no-log.js' was not found
I want to create couple of custom rule for my nodejs project by eslint and generate
one json analysis report but while running my custom rules it's throwing an error say
1:1 error Definition for ...
0
votes
0
answers
10
views
Error: Failed to load config "plugin:@stylistic" to extend from
I'm trying to follow this guide here:
https://eslint.style/packages/default
First I installed the package with command:
npm i -D @stylistic/eslint-plugin
In the guide it is using .eslintrc.js but I ...
-1
votes
0
answers
38
views
What ESLint rule forces each parameter of a function definition into a new line
In my code I have something like:
sap.ui.define(
[
"a",
"b",...
],
function (
a, b, c, ...
) {
...
but I want it to look like:
sap.ui.define(
[
&...
0
votes
1
answer
17
views
ESLint Unable to Resolve TypeScript Path Aliases in Node.js Project
I am working on a Node.js project using TypeScript, and I have set up path aliases in my tsconfig.json. However, ESLint is unable to resolve these path aliases, resulting in the error: Unable to ...
-1
votes
0
answers
19
views
Can't enable `eslint-disable object-curly-newline globally` using .eslintrc.json
Currently, I use /* eslint-disable object-curly-newline */ at the top of most of my components. Since it's a de-facto default, I tried to turn it off globally using .eslintrc.json (with inspiration ...
0
votes
1
answer
31
views
import/order unable to recognise unnamed imports?
The specific rule import/order from eslint-plugin-import does not seem to recognise the unnamed imports such as import moment/locale/fr: to clarify, I need to import moment like this (as the ...
1
vote
1
answer
44
views
Can we disallow to use || on optional types by lint?
I want to disallow following code:
function(num: undefined|number) {
return num || 10;
}
I want use ?? instead of ||.
-1
votes
0
answers
44
views
TypeScript Compiler is taking way too long to run
A few weeks back, running yarn tsc --noEmit started to take way too long that isn't even possible to run it without it crashing due to an out-of-memory error:
<--- Last few GCs --->
[3039:...
0
votes
0
answers
20
views
Configure multi-line function call indentation in eslint
How do I configure the eslint indent rules for function calls that span multiple lines?
For example, in the following code, with the indent set to 2, eslint complains that the second line of the ...
-1
votes
1
answer
43
views
Configure ESLint that optional parameters in brackets
How can I configure ESLint so that it checks that required parameters are written in JSDoc without brackets, and optional parameters are written in brackets?
Example
/**
* Function params
*
* @...
0
votes
0
answers
19
views
FontAwesomeIcon with Nuxt 3 raises two lint errors in my code
I am using Nuxt 3 and want to have fontawesome. It actually works, but I have some lint errors that I am not getting rid of and I want to understand if I did something wrong or not.
Here's part of the ...
0
votes
1
answer
11
views
adding "fix:" to my custom eslint rule causes an error when trying to run "npx eslint <file_path>"
I created a custom eslint rule that is flagging in a ton of spots in the codebase so I want to add my own fix for the rule so that the change can be automated but it wont work.
The following code ...
1
vote
0
answers
22
views
@typescript-eslint/naming-convention - How to use to enforce consistent `catch` variable names?
This seems to be possible with https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/rules/catch-error-name.js but I didn't want to re-implement this if @typescript-eslint could ...
0
votes
0
answers
18
views
Failing to apply lint parserOptions.project pointing at project tsconfig.json after Angular migration
To migrate Angular 15 to Angular 16.2.x I also had to update devDependencies, including eslint from ~8.33.0 to ^8.39.0
Now I am receiving the error message:
You have attempted to use a lint rule ...
3
votes
0
answers
58
views
ESLint rule conflicts for spacing in try/catch clause, typescript
I have written a custom rule to enforce spacing in the catch block to follow the format below:
try {
} catch(err) {
}
And
try {
} catch {
}
My issue is that my keyword-spacing rule conflicts with my ...
2
votes
1
answer
51
views
Firebase deploy error - Running command: npm --prefix "$RESOURCE_DIR" run lint results in /bin/sh: 0: Illegal option --
I've deployed without issue a thousand times, running lint each time, now all of a sudden I'm getting an Illegal option -- error and deploy fails.
firebase --version: 12.9.1 node -v v16.16.0 yarn --...
-1
votes
0
answers
24
views
How to support '.gql' files for EsLint and Prettier in VS Code
In my project I have some .gql files:
src/components/mycomponent/MyComponent.gql
import { gql } from '@apollo/client';
export default gql`
query MyQuery {
myQuery {
test
}
}
`
In ...
0
votes
1
answer
50
views
How to use new ESLint Configuration File syntax with extensions and TypeScript
Been looking everywhere for an example of this but have not found one and have not had success setting it up myself. I am trying to leverage the new ESLint Configuration File format for my React ...
2
votes
1
answer
45
views
When a useCallback function is called both by a useEffect and an onClick handler is there a way to have exaustive deps to the useEffect?
I have a pseudo-code React component similar to this one:
const codeApplier = ({ code, prices }: Props) => {
const [isAccepted, setIsAccepted] = useState(false);
const applyCode = useCallback(...
1
vote
1
answer
103
views
In VSCode, how do I effectively run eslint --fix and prettier --write on "Format Document"?
For context, I've locally installed prettier, eslint, and their respective VS Code extensions. I used the word "effectively" in my title because I don't literally need to run eslint --fix; ...
0
votes
0
answers
42
views
Nuxt 3 'Vue: Cannot find name computed' error for PyCharm IDE
I'm developing a project with Nuxt 3 for learning fundamentals. I am using PyCharm IDE and have encountered an issue.
Issue Description:
const userName = computed(() => store.user.name)
In my Vue ...
0
votes
1
answer
18
views
How to setup VSCode to use local ESLint over the global configuration?
If I have a global ESLint configuration and a local one, I want to automatically use the local lint configuration over the global one.
Otherwise, I want to use the global config.
1
vote
1
answer
52
views
Angular 15: error "subscribe is deprecated" still present after changes
I use Webstorm editor and I work with Angular 15.
I get the following message for subscribe function : "Deprecated symbol used"
I found this post and on the rxjs site that the method has ...
0
votes
0
answers
20
views
Eslint flat config + feature-sliced.design + monorepo
Official FSD site provides FAQ on linting topic
I tried plugin, which is works perfectly inside one specific repo. But when I tried to put plugin in monorepo flat config, it started to behave ...
0
votes
1
answer
95
views
ESLint with Typescript: SyntaxError: Unexpected token '||=' in node_modules folder
I'm trying to use ESLint with a pretty basic typescript project and I'm running into errors with the setup.
Description:
It seems that ESLint is picking up errors in the node_modules folder, despite ...
0
votes
0
answers
30
views
I have set eslint single quotes with .eslintrc.cjs. But when i save file vscode auto change to double quotes
This is my .eslintrc.cjs
module.exports = {
root: true,
env: {
browser: true,
commonjs: true,
es6: true,
jest: true,
node: true,
},
extends: [
'eslint-config-react-app',...
1
vote
0
answers
127
views
AST selector for eslint rule for Angular ngOnChanges method
The idea is to validate ngOnChanges Angular method.
it should have changes of type SimpleChanges as an argument
inside the function when accessing the property currentChanges should be optionaly ...
0
votes
2
answers
245
views
How to solve "Error while loading rule 'react/display-name': `[[GeneratorState]]` is not present on `O`" error in eslint
In my case I am using eslint on nextjs with eslint-config-next. I use bun as a package manager but I found instances of this issues on npm and yarn as well.
I didn't add any new package but after ...
0
votes
0
answers
81
views
React Failed to Compile (Linter)
I am having a series of bugs when attempting to "npm run build" my application
The first error I received was:
Failed to compile.
Cannot read property 'value' of null
Occurred while linting ...
1
vote
1
answer
15
views
Overriding function type signatures which return any
I am using a function from a package which returns a value as any;
// node_modules/reflect-metadata/index.d.ts
function getMetadata(metadataKey: any, target: Object): any;
Like so;
const example = ...
0
votes
0
answers
24
views
How to configure eslint in Bazel environment for typescript project
Tried configuring as below:
load("@npm//eslint:index.bzl", "eslint_test")
eslint_test(
name = "eslint",
config = "//ui/web:.eslintrc.js",
)
Ran command: bazel ...
0
votes
0
answers
5
views
varsIgnorePattern to ignore unused class names
How can an ignore be set for the unused class names (there are a few) used in Side Effect modules?
class Something {
static {
this.set();
}
static set() {
// do something
}
}
....
0
votes
0
answers
19
views
There is a similar rule to vue/padding-line-between-tags form ANGULAR, for html template?
This not working! I would like add blank line space between tags to separate concept between elements in HTML file. I use VSCODE. I execute script "lint:check": "ng lint", (ESLINT) ...
0
votes
0
answers
31
views
eslint parsing error with vuejs and typescript
I have a vue project with an interface defined like
export interface Task {
id?: number;
title: string;
description: string;
assigned?: string | null;
dueDate?: Date | null;
completedDate?: Date | ...
0
votes
2
answers
72
views
Getting this Error somtimes when I run 'npm start' Command for my React project
Failed to compile.
[eslint] Plugin "react" was conflicted between "package.json » eslint-config-react-app » C:\Users\dell\desktop\text-to-speech\node_modules\eslint-config-react-app\...
0
votes
0
answers
58
views
How do I get Eslint to recognize nuxt auto-import functions?
I have a new Nuxt 3 project in which I am using functions that are auto-imported by Nuxt such as 'useCookie', 'useRouter', 'ref', etc.. The functions are working as intended when I run the app, but ...
0
votes
0
answers
32
views
Usage of @eslint/config tool with airbnb and prettier plugins
Following eslint QuickStart documentation, I run the npm init @eslint/config and got a boilerplate .eslintrc as expected:
module.exports = {
"env": {
"browser": true,
...
0
votes
0
answers
26
views
How to run ESLint in Next.js using yarn dev
I'm using Next.js version 13, and I want to run ESLint when running 'yarn dev.'
In a previous project where I used TypeScript with Next.js, ESLint would run when I executed 'yarn dev,' and it would ...
0
votes
0
answers
48
views
How to disable bang operator (!) in property initialization in js/ts
Since I have set strict: true style rule, I will get the Property has no initializer and is not definitely assigned in the constructor.ts(2564) error if I don't set initiation on a variable. I am able ...
0
votes
0
answers
63
views
EslintPluginImportResolveError: unable to load resolver "alias"
We have just done our weekly Dependancy updates and now our eslint process throws the following error
EslintPluginImportResolveError: unable to load resolver "alias".
Occurred while linting /...
-1
votes
1
answer
345
views
EsLint error : Classname is not a Tailwind CSS class
I keep having an EsLint error "className is not a TailwindCSS class" after adding some custom classes likes colors in my tailwindd.config.js and I don't find how to solve this problem....
0
votes
1
answer
57
views
Vue.js + Pinia: How can I solve problems found by ESLint and TypeScript? [duplicate]
I'm new to Vue.js + Pinia. I would like to know how to solve these messages.
'state:' is defined but never used.
The code below is @/stores/user.ts.
import { defineStore } from 'pinia'
export const ...
0
votes
1
answer
273
views
ESLint: Mixed spaces and tabs. (no-mixed-spaces-and-tabs)
When I reformatting my code with ctrl + alt + L in WebStorm I see this error ESLint: Mixed spaces and tabs. (no-mixed-spaces-and-tabs)Eslint error
I again install eslint add settings for eslint in ...
1
vote
2
answers
29
views
Stop no-unused-expressions on svelte $ assignments
I'm trying to setup an ESLint using the libs eslint, typescript-eslint (along with its parser) & eslint-plugin-svelte, but each time I write something along the lines of
$: somevar, somefunction();...
2
votes
0
answers
37
views
Why does Next.js 13 ESLint --fix flag not fix the ESLint warnings and errors?
So below is the package.json file, and from what I've seen on other code bases and tutorials this should work, i.e. running npm run lint:fix should fix the errors and warnings I get when I run npm run ...