Giter Site home page Giter Site logo

wlx200510 / eslint-config-azedo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azedo/eslint-config-azedo

0.0 1.0 0.0 287 KB

Eslint and Prettier setup based on my most used configurations. This was initially meant to be used by me in my projects, but feel free to use and/or extend it if you feel like it.

Home Page: https://www.npmjs.com/package/eslint-config-azedo

JavaScript 100.00%

eslint-config-azedo's Introduction

Eslint Config

Opinionated eslint defaults for js/node repositories. If you need to check the documentation in order to overwrite some rules in your repository, go to https://eslint.org/docs/rules/ and have a look.

How to use it?

  1. If you don't already have a package.json file, create one with npm init.

  2. Then you need to install the packages needed by the config

npx install-peerdeps --dev eslint-config-azedo
  1. Now, if you have a look at your package.json file, you can see that it has a bunch of new packages under devDependencies

  2. Next you need to import this config in your .eslintrc in order to use them. (The react config is enabled by default, but in case you want to use the node config just change the extends string to eslint-config-azedo/node-config)

module.exports = {
  extends: ['eslint-config-azedo']
}
  1. You can also use our automated script in order to create the .eslintrs.js, .prettierrc.js and vscode/settings.json files (they will not be replaced in case you already have them!)
# Run this on your project's main folder (root folder)
./node_modules/eslint-config-azedo/utils/setup.js

# You can also use the node command if you prefer (you don't need to!)
node node_modules/eslint-config-azedo/utils/setup.js
  1. Lastly, don't forget to add a script in your package.json file to run these rules against your codebase.
"scripts": {
   "lint": "eslint '*/**/*.{js,jsx,ts,tsx}' --fix"
}
  1. And that's it! Now you should be able to run these rules whenever you want.

  2. One suggestion is that you add the script above lint in your repo:

    • As a pre-push hook (with husky):
     "husky": {
       "hooks": {
         "pre-push": "npm run lint"
       }
     }
    • And/or as a step in your CI pipelines
    linting:
      stage: codeQuality
      script:
        - npm run lint
  3. One last thing. Feel free to customize these rules in your repository by overwriting them in the .eslintrc file or adding more rules that are necessary (or make more sense) for your codebase.

Known issues

  • If you can't use the automated script (because you already had the package in your repo), delete the node_modules folder from your repo and install this config package again!
# On your project's main folder (root folder), type - PLEASE BE CAREFUL WITH THIS RM COMMAND!!!!!
rm -rf node_modules

# Then, in the same main folder (root folder), install the project's dependencies again (since they should already be in package.json, just run the global npm install command)
npm i

eslint-config-azedo's People

Contributors

azedo 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.