Coder Social home page Coder Social logo

marcelmokos / eslint-config-with-prettier Goto Github PK

View Code? Open in Web Editor NEW
40.0 3.0 13.0 540 KB

Eslint config with prettier

License: MIT License

Shell 2.69% JavaScript 97.31%
eslint eslint-config eslintrc airbnb react flowtype editorconfig testing jest enzyme

eslint-config-with-prettier's Introduction

eslint-config-with-prettier

npm version styled with prettier Build Status dependency devDep Known Vulnerabilities

This package provides Airbnb's .eslintrc.yml with prettier as an extensible shared config.

  • If you do not want to install and setup eslint with all configs and plugins.
  • Install and extend eslint-config-with-prettier it works as create-react-app but for eslint, linting with prettier.

Usage

1. install config

yarn add --dev eslint-config-with-prettier

or

npm install --dev eslint-config-with-prettier

2. extend config

  • .eslintrc.yml
extends:
  - eslint-config-with-prettier
  • .eslintrc.js
module.exports = {
  extends: ["eslint-config-with-prettier"],
};
  • .eslintrc.json
{
  "extends": ["eslint-config-with-prettier"]
}

You can expect

  • linting using eslint
  • extended Airbnb config
  • pretty printing using prettier on eslint --fix
  • bash script for additional setup

Tools:

Configs:

Plugins:

adding support to eslint-plugin-dollar-sign

  • helpful for ES6 code that uses jQuery
extends:
  - eslint-config-with-prettier
plugins:
  # https://github.com/erikdesjardins/eslint-plugin-dollar-sign
  - dollar-sign
rules:
  # Require dollar sign for some variables that holds jQuery objects
  dollar-sign/dollar-sign:
    - error
    - ignoreProperties
  • .eslintrc.js
module.exports = {
  extends: ["eslint-config-with-prettier"],
  plugins: ["dollar-sign"],
  rules: {
    "dollar-sign/dollar-sign": ["error", "ignoreProperties"],
  },
};
  • .eslintrc.json
{
  "extends": ["eslint-config-with-prettier"],
  "plugins": ["dollar-sign"],
  "rules": {
    "dollar-sign/dollar-sign": ["error", "ignoreProperties"]
  }
}

running setup script

✋!!!on your own risk!!!✋, commit before running the script and control the output using diff in version control.

setup.sh that run gist example

bash ./node_modules/eslint-config-with-prettier/setup.sh

If you do not want to run the bash script you can simply copy files into your project.

This script adds useful files into your project.

"scripts": {
  "test": "jest",
  "test:changed": "yarn test --onlyChanged --passWithNoTests --silent --runInBand",
  "test:watch": "yarn test --watch",
  "test:update": "yarn test --update",
  "test:coverage": "yarn test --coverage --verbose --silent --runInBand --passWithNoTests",
  "lint": "eslint . --cache",
  "lint:fix": "yarn lint --fix",
  "lint:staged": "eslint --fix --max-warnings=0",
  "precommit": "lint-staged && yarn test:changed",
  "prepush": "yarn test:coverage",
  "prettier": "prettier --write *.{js,jsx,html,md,mdx,yaml,json,css,scss,less}",
},
"husky": {
  "hooks": {
    "pre-commit": "yarn precommit",
    "pre-push": "yarn prepush"
  }
},
"lint-staged": {
  "linters": {
    "*.{js,jsx}": [
      "yarn run lint:staged",
      "git add"
    ],
    "*.{json,css,scss,less}": [
      "prettier --write",
      "git add"
    ],
    "*.{png,jpeg,jpg,gif,svg}": [
      "imagemin-lint-staged",
      "git add"
    ]
  }
}
"scripts": {
  "flow:setup": "yarn && flow-typed install",
  "flow:update": "flow-typed update",
  "flow": "flow",
  "flow:errors": "flow --show-all-errors",
  "flow:coverage": "flow coverage ./src/index.js --color && flow-coverage-report -i src/**/*.js -x src/**/*.test.js -x src/**/*.spec.js -t html",
  "prepush": "yarn test:coverage && yarn run flow:errors"
}

eslint-config-with-prettier's People

Contributors

marcelmokos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eslint-config-with-prettier's Issues

Eslint breaks with v5.10.0

When upgrading eslint from v5.9 to v5.10, it failed due to mandatory plugin eslint-plugin-dollar-sign that it cannot find.
Removing eslint-config-with-prettier seems to fix the issue.

Related issue: eslint/eslint#11177

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.