Nameless Package Manager

    This package has been deprecated

    Author message:

    This eslint config is no longer maintained in favor of @virtuous/eslint-config

    eslint-config-affinita

    1.1.0 • Public • Published

    Affinita eslint configuration

    Travis CI Build GitHub release Coverage Status License

    This eslint configuration extends the default configuration from Airbnb. It brings everything you need to start with it.

    Installation

    npm i eslint-config-affinita --save-dev
    

    Usage

    Add the following to the .eslintrc in your project:

    {
      "extends": "affinita",
      ...
    }
    

    Rules

    We have some extra rules implemented that extend Airbnb's Default Codestyle. We strongly recommend to read those default rules first to get into the basics!

    1. General
      1.1. Commented out code
      1.2. Comma dangle
      1.3. Multiple empty lines
    2. Functions
      2.1. Point free
    3. Objects
      3.1. Single line objects
    4. Documentation
      4.1. JSDoc requirement
    5. React
      5.1 Prop Types

    1. General

    1.1 Commented out code

    No code should be left commented out.

    /**
     * static propTypes = {
     *    width: PropTypes.string.isRequired,
     *    color: PropTypes.string,
     *    height: PropTypes.string.isRequired,
     * };
     */

    ⬆ back to top

    1.2 Comma dangle

    Dangling commas are required for objects with multiple items or properties. This applies to Array, Object, Import and Export.

    // bad
    const myObject = {
      a: 1,
      b: 2
    };
     
    // good
    const myObject = {
      a: 1,
      b: 2,
    };
     
    // bad
    import { var1, var2, var3 } from 'Variables';
     
    // good
    import {
      var1,
      var2,
      var3,
    } from 'Variables';

    ⬆ back to top

    1.3 Multiple empty lines

    There should not be multiple empty lines between code blocks.

    // bad
    const a = 1;
    const b = 1;
     
     
    while (...) {
      ...
    }
     
    // good
    const a = 1;
    const b = 2;
     
    while (...) {
      ...
    }

    ⬆ back to top

    2. Functions

    2.1 Point free

    A function should not simply call another function.

    // bad
    const funcA = (params) {
      ...
    };
     
    const funcB = (params) {
      funcA(params);
    };
     
    // good
    const funcAB = (params) {
      ...
    }

    ⬆ back to top

    3. Objects

    3.1 Single line objects

    If an object is defined with multiple properties then each property should occupy a new line.

    // bad
    const x = { a: 1, b: 2, c: 3 };
     
    // good
    const w = { a: 1 };
    const x = {
      a: 1,
      b: 2,
      c: 3,
    };

    ⬆ back to top

    4. Documentation

    4.1 JSDoc requirement

    Every Function, Class, Method and Arrow Function definition should include a valid JSDoc specification.

    // bad (missing parameter descriptions)
    /**
     * This is funcA. It does something complicated.
     */
    const funcA = (param1, param2) {
      ...
    };
     
    // bad (invalid specification)
    /**
     * This is funcB. It also does something complicated.
     * @param {Object} parameters 
     */
    const funcB = (param1, param2) {
      ...
    };
     
    // good
    /**
     * It does something simple because we are using our heads.
     * @param {string} param1 My first parameter.
     * @param {boolean} param2 My Second parameter.
     */
    const funcC = (param1, param2) {
      ...
    };

    ⬆ back to top

    5. React

    5.1 Prop Types

    PropTypes should be sorted by type (required or not) and alphabetically.

    // bad
    static propTypes = {
      width: PropTypes.string.isRequired,
      color: PropTypes.string,
      height: PropTypes.string.isRequired,
    };
     
    // good
    static propTypes = {
      height: PropTypes.string.isRequired,
      width: PropTypes.string.isRequired,
      color: PropTypes.string,
    };

    ⬆ back to top

    License

    Affinita's eslint configuration is available under the MIT License.

    See the LICENSE file for more information.

    Install

    npm i eslint-config-affinita

    DownloadsWeekly Downloads

    4

    Version

    1.1.0

    License

    MIT

    Last publish

    Collaborators

    • flomueller