All Questions
105
questions
1
vote
2
answers
75
views
How to use Eslint rule for JSX attribute value
I want to apply eslint rule for JSX attribute value.
like I have a component having some attribute for example
<Component
attribute1="abc-efg"
/>
In above example I want to place a ...
0
votes
0
answers
35
views
ESLint not working with JSX or JS files but works fine with TS and TSX files
Had this similar issue when using Prettier. I'm on macOS and the only project I had so far in VS Code used exclusively TypeScript and no JSX files at all. When I switched to a project where we are ...
3
votes
5
answers
2k
views
Unknown word (CssSyntaxError) in JSX File (react js)
I'm working on a React project and have run into an issue where ESLint is throwing an Unknown word (CssSyntaxError) when linting my JSX files. This error seems to be related to CSS parsing within JSX, ...
0
votes
0
answers
67
views
A form label must be associated with a control - jsx-a11y/label-has-associated-control
I have a html code block as in below in my react application which throws "A form label must be associated with a control" eslint warning under jsx-a11y/label-has-associated-control.
<...
2
votes
1
answer
313
views
ESLint to remove unnecessary braces on React properties?
Is there any way to get ESLint to automatically flag/fix properties in JSX which have an unnecessary curly brace?
<HStack mt={"xl"} ... />
...would become...
<HStack mt="xl&...
0
votes
0
answers
157
views
TypeScript Parsing Error with JSX Element in Object - React with TypeScript
I'm working on a React project with TypeScript and encountering a parsing error when trying to include a JSX element (an icon from the React-Icons library) within an object. This object is part of a ...
1
vote
1
answer
130
views
I wanted to rewrite my project in typescript, but there is a problem in the App.tsx file
I have ESLint errors that occur in the App.js file, which is created automatically when compiling my App.tsx, which contains a simple component. How to solve this problem?
There is an error example:
[...
0
votes
1
answer
424
views
eslint rule to require a specific prop for a react component?
I am using a 3p component library that I cannot modify. However, I want to always require a specific component prop when it's used in a form. Here's an example:
<div className="my-header-...
0
votes
0
answers
199
views
Eslint removing JSX component props indentation when rendering with ternary
I want indentation of component props when rendering with a ternary like this:
return (
<div>
<h2>
blogs
</h2>
{user === null
? <LoginForm
...
1
vote
0
answers
30
views
Is there an ESLint rule to find files with a `.jsx` file extension which don't contain actual JSX?
I've found several files in my project which used to contain JSX in them, but don't anymore, i.e. they could be renamed to .js/.ts. I would like to find such files automatically and would have thought ...
3
votes
1
answer
268
views
How to configure ESLint to add an empty line between same-level JSX blocks?
Is there a configuration option in ESLint or any other tool that can automatically add an empty line between JSX blocks that are at the same level?
For example, consider the following JSX code:
<...
1
vote
1
answer
3k
views
Eslint 'React' must be in scope when using JSX react/react-in-jsx-scope
When I run yarn eslint . I got this result:
5:10 error 'React' must be in scope when using JSX react/react-in-jsx-scope
✖ 1 problem (1 error, 0 warnings)
The problem is that in this file, I ...
0
votes
1
answer
685
views
eslint jsx-a11y label must be associated with a control error
The <label> in this code is being rejected by the eslint jsx-a11y plugin:
A form label must be associated with a control. eslint(jsx-a11y/label-has-associated-control)
<div className="...
0
votes
1
answer
76
views
How to disable typescript linting in nuxt3?
In my nuxt3 project I want to use jsx to create dynamic virtual dom. To achieve that I used
by following this example given in offical doc.
<script lang='tsx' setup>
...
</script>
by ...
0
votes
1
answer
472
views
Typescript sorting Type by required first
I am looking for a plugin or ESLint rule that makes the case that sorting of types will be done by assuming required first while not required below.
Example before:
type TExampleSorting = {
title?: ...