edenspiekermann / espi-eslint-config Goto Github PK
View Code? Open in Web Editor NEWESLint configuration
ESLint configuration
I would propose the following approach:
from 'blah';
from '../../../blubb;
from './nuff;
Since we used named imports as well, they should also be sorted here: import { Ahh, Beh, Ceh } from './alphabet
;
Example:
import { Field, Fromik } from 'formik';
import { Link } from 'gatsby';
import nanoid from 'nanoid';
import { bool, number, string } from 'prop-types';
import React, { useCallback, useMemo } from 'react';
import BEMHelper from 'react-bem-helper';
import { Button } from '../../shared/button';
import { Container, Layout } from '../../shared/layout';
import { Banner, Text } from '../commons';
import { Item } from './item';
import 'example.scss';
Use quoting for object properties only when needed. If needed, use it consistently:
const obj = {
'foo': 'bar',
};
const obj = {
foo: 'bar',
};
const obj = {
'0': 'zero',
'non-valid-if-unquoted-prop': true,
};
const obj = {
'0': 'zero',
'non-valid-if-unquoted-prop': true,
foo: 'bar', // needs quoting because of the rest
};
Add the following rule:
'quote-props': ['error', 'consistent-as-needed'],
See: https://eslint.org/docs/rules/quote-props#consistent-as-needed
The current validation configuration enforces the following format of switch/case statements:
switch(a){
case "a":
break;
case "b":
break;
}
We should use the eslint default configuration that looks like this:
switch(a){
case "a":
break;
case "b":
break;
}
Add react-hooks plugin by default for a react configs: https://reactjs.org/docs/hooks-rules.html#eslint-plugin
This should extend from plugin:react-hooks/recommended
configuration: https://github.com/facebook/react/tree/master/packages/eslint-plugin-react-hooks#eslint-plugin-react-hooks
When running eslint
with the espi config, the following warning appears:
(node:3767) [ESLINT_LEGACY_OBJECT_REST_SPREAD] DeprecationWarning: The
'parserOptions.ecmaFeatures.experimentalObjectRestSpread' option is deprecated. Use
'parserOptions.ecmaVersion' instead. (found in "node_modules/eslint-config-airbnb-base/index.js")
Probably due to an outdated version of the Airbnb config.
The export rule for modules disallows only named modules and prefers a default export:
export default const Component = () => { ... };
Disabling the rule import/prefer-default-export
would allow the usage of named exports:
export const Component = () => { ... };
Benefits:
See: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
Change current setting to:
'import/prefer-default-export': ['off'],
The no-param-reassign
rule does not allow props reassignment.
To fix the behaviour and allow props reassignment, add the following rule: 'no-param-reassign': ['error', { 'props': false }]
The dependencies @typescript-eslint/eslint-plugin
and @typescript-eslint/parser
needed to be updated >=2.7.0 to support TypeScript 3.7 features like optional chaining.
https://github.com/typescript-eslint/typescript-eslint/releases
Should we allow props speading (react/jsx-props-no-spreading
) like:
const Component = (props) => (
<OtherComponent {...props} />
);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.