Coder Social home page Coder Social logo

espi-eslint-config's People

Contributors

dependabot[bot] avatar dsteinel avatar jankohofmann avatar kojinkai avatar schorfes avatar sigmarstern avatar yvesrijckaert avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

espi-eslint-config's Issues

Import ordering and grouping

I would propose the following approach:

  1. 3rd party imports, sorted alphabetically based on the from 'blah';
  2. ---newline---
  3. global imports, sorted from farthest to nearest and then alphabetically from '../../../blubb;
  4. ---newline---
  5. local imports, sorted alphabetically 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';

Quote props in a consistent way

Use quoting for object properties only when needed. If needed, use it consistently:

  • No need for quoting, this will be reported
const obj = {
    'foo': 'bar',
};
  • No need for quoting, this is correct
const obj = {
    foo: 'bar',
};
  • A need for quoting
const obj = {
    '0': 'zero',
    'non-valid-if-unquoted-prop': true,
};
  • A need for quoting, but inconsistently used โ€“ this will be reported
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

Deprecated Feature Warning: ESLINT_LEGACY_OBJECT_REST_SPREAD

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.

Prefer / allow named module exports

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:

  • Multiple exports per file (if necessary)
  • Consistent names between exports and imports (easier refactoring and searchability in project)
  • Possibly better three shaking

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'],

Allow props reassignment

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 }]

Allow props spreading

Should we allow props speading (react/jsx-props-no-spreading) like:

const Component = (props) => (
  <OtherComponent {...props} />
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.