eslint-config-airbnb

Typescript baseUrl not working in React Typescript project

孤街醉人 提交于 2021-02-11 04:31:35
问题 I defined the baseUrl in my tsconfig.json file: "baseUrl": "src", In .eslintrc.js I have: parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 2018, sourceType: 'module', project: './tsconfig.json', }, Now in e.g. index.tsx I can import my components like import Layout from 'components/layout'; When I run gatsby develop I get some errors like: If you're trying to use a package make sure that 'components/layout' is installed. If you're trying to use

Typescript baseUrl not working in React Typescript project

早过忘川 提交于 2021-02-11 04:31:33
问题 I defined the baseUrl in my tsconfig.json file: "baseUrl": "src", In .eslintrc.js I have: parser: '@typescript-eslint/parser', parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 2018, sourceType: 'module', project: './tsconfig.json', }, Now in e.g. index.tsx I can import my components like import Layout from 'components/layout'; When I run gatsby develop I get some errors like: If you're trying to use a package make sure that 'components/layout' is installed. If you're trying to use

Must use destructuring props assignment (react/destructuring-assignment)

别说谁变了你拦得住时间么 提交于 2021-01-13 08:31:53
问题 I've applied eslint airbnb standard to my code, so now this code: handleSubmit = (event) => { event.preventDefault(); this.props.onSearch(this.query.value); event.target.blur(); } causes this error: [eslint] Must use destructuring props assignment (react/destructuring-assignment) onSearch basically a trigger that passes up a value to parent component. How do I refactor this code to meet the eslint requirements? 回答1: handleSubmit = (event) => { event.preventDefault(); const {onSearch} = this

How to use ESLint TypeScript Airbnb configuration?

谁都会走 提交于 2020-12-15 06:50:56
问题 I try to install and use ESLint Airbnb configuration for TypeScript for several days and I cannot make it work. Can somebody give installation and configuration steps of a working configuration, please? Below is one of my attempts to lint this code base using Airbnb convention. Airbnb configuration doesn't support Typescript ESLint 3.0 yet, so I will install TypeScript ESLint 2.34. Typescript ESLint 2.34 doesn't support ESLint 7 yet, so I will install ESLint 6.x. Typescript ESLint 2.34 doesn

React-navigation, tintColor is missing in props validation

允我心安 提交于 2020-05-15 04:15:28
问题 I have put my react-navigation code into a separate Routes file which I am then importing into my App.js file. Everything is working fine but I am using Airbnb ESLint config in Atom/Nuclide and getting an error with tintColor... "tintColor is missing in props validation" Tried this: Routes.propTypes = { tintColor: PropTypes.string.isRequired,} But then get error "tintColor PropType is defined but prop is never used" This is part of the code const Routes = () = { const ContentNavigator =

how to exclude css files from eslint parser in React

孤人 提交于 2020-04-10 08:35:11
问题 I need to exclude css files from the eslint parser. Currently when I run eslint src/** this is checking all the files including css files. . Please find below my eslintrc file contents. module.exports = { "parser": "babel-eslint", "extends": "airbnb", "plugins": [ "react", "jsx-a11y", "import" ], "env" : { "browser": true } "rules": { "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], }, }; 回答1: .eslintignore file to ignore styles would work nicely. Inside, do something

how to exclude css files from eslint parser in React

跟風遠走 提交于 2020-04-10 08:35:08
问题 I need to exclude css files from the eslint parser. Currently when I run eslint src/** this is checking all the files including css files. . Please find below my eslintrc file contents. module.exports = { "parser": "babel-eslint", "extends": "airbnb", "plugins": [ "react", "jsx-a11y", "import" ], "env" : { "browser": true } "rules": { "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], }, }; 回答1: .eslintignore file to ignore styles would work nicely. Inside, do something

Caught between two no-restricted-syntax violations

冷暖自知 提交于 2020-02-21 10:10:45
问题 This is my original code: const buildTableContent = (settings) => { const entries = []; for (const key in settings) { for (const subkey in env[key]) { settings is basically a dictionary of dictionary { 'env': {'name': 'prod'}, 'sass: {'app-id': 'a123445', 'app-key': 'xxyyzz'} } It triggered the following AirBnb style guide error: 35:3 error for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the

Caught between two no-restricted-syntax violations

佐手、 提交于 2020-02-21 10:09:45
问题 This is my original code: const buildTableContent = (settings) => { const entries = []; for (const key in settings) { for (const subkey in env[key]) { settings is basically a dictionary of dictionary { 'env': {'name': 'prod'}, 'sass: {'app-id': 'a123445', 'app-key': 'xxyyzz'} } It triggered the following AirBnb style guide error: 35:3 error for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the

Prevent using this.state within a this.setState (react/no-access-state-in-setstate)

∥☆過路亽.° 提交于 2020-01-06 05:05:27
问题 For this piece of code, !this.state.dark I am getting an ESlint (airbnb config) error: Use callback in setState when referencing the previous state. I tried refactoring the code using following the ESlint documentation. But I'm having a hard time figuring it out. Any suggestions on how I can solve this problem? toggleDark = () => { const dark = !this.state.dark localStorage.setItem('dark', JSON.stringify(dark)) this.setState({ dark }) } 回答1: Thanks to @jonrsharpe for pointing me to