GithubHelp home page GithubHelp logo

mianhaseeb1 / eslint-prettier-airbnb-react Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paulolramos/eslint-prettier-airbnb-react

0.0 1.0 0.0 33 KB

ESlint + Prettier + Airbnb Style Guide Configuration for React

License: GNU General Public License v3.0

Shell 100.00%

eslint-prettier-airbnb-react's Introduction

Installation

  1. Navigate to your app directory where you want to include this style configuration.

    cd my-app
  2. Run this command inside your app's root directory. Note: this command executes the eslint-prettier-config.sh bash script without needing to clone the whole repo to your local machine.

    exec 3<&1;bash <&3 <(curl https://raw.githubusercontent.com/paulolramos/eslint-prettier-airbnb-react/master/eslint-prettier-config.sh 2> /dev/null)
  3. Make selections for your preference of package manager (npm or yarn), file format (.js or .json), max-line size, and trailing commas (none, es5, all).

  4. Look in your project's root directory and notice the two newly added/updated config files:

    • .eslintrc.js (or .eslintrc.json)
    • .prettierrc.js (or .prettierrc.json)

Packages

Main Packages

  1. ESlint
  2. Prettier

Airbnb Configuration

  1. eslint-config-airbnb
    • This package provides Airbnb's .eslintrc as an extensible shared config.
  2. eslint-plugin-jsx-a11y (Peer Dependency)
    • Static AST checker for accessibility rules on JSX elements.
  3. eslint-plugin-react (Peer Dependency)
    • React specific linting rules for ESLint
  4. eslint-plugin-import (Peer Dependency)
    • Support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names.
  5. babel-eslint

ESlint, Prettier Integration

  1. eslint-plugin-prettier
    • Runs Prettier as an ESLint rule and reports differences as individual ESLint issues.
  2. eslint-config-prettier
    • Turns off all rules that are unnecessary or might conflict with Prettier.

Created Configuration Files

Once files are created, you may edit to your liking.

eslintrc(.js/.json)

{
"extends": [
    "airbnb",
    "plugin:prettier/recommended",
    "prettier/react"
  ],
  "env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "jest": true,
    "node": true
  },
  "rules": {
    "jsx-a11y/href-no-hash": ["off"],
    "react/jsx-filename-extension": ["warn", { "extensions": [".js", ".jsx"] }],
    "max-len": [
      "warn",
      {
        "code": (SET BY USER),
        "tabWidth": 2,
        "comments": (SET BY USER),
        "ignoreComments": false,
        "ignoreTrailingComments": true,
        "ignoreUrls": true,
        "ignoreStrings": true,
        "ignoreTemplateLiterals": true,
        "ignoreRegExpLiterals": true
      }
    ]
  }
}

prettierrc(.js/.json)

{
"printWidth": (SET BY USER),
  "singleQuote": true,
  "trailingComma": (SET BY USER)
}

This script was inspired by Jeffrey Zhen's tutorial.

eslint-prettier-airbnb-react's People

Contributors

paulolramos avatar jondkinney avatar

Watchers

James Cloos avatar

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.