Giter Site home page Giter Site logo

eslint-config-eda's Introduction

eslint-config-eda

Linting configuration for Enspiral Dev Academy (EDA) challenges and projects.

Installation

npm i -D eslint prettier eslint-config-eda

Peer dependencies

If your npm version is between earlier than 7, it will not install peer-dependencies automatically, instead it will print a warning when you install eslint-config-eda

You can see your npm version with the -v or --version flag. This is what it looks like with npm v8.4.1

$ npm -v
8.4.1

if your version is between 5.2-6.x, you can run the following to install the peer dependencies of eslint-config-eda

$ npx install-peerdeps --dev eslint-config-eda
install-peerdeps v3.0.3
Installing peerdeps for eslint-config-eda@latest.
npm install [email protected] eslint@^8.8.0 eslint-plugin-import@^2.25.4 eslint-plugin-jest@^26.0.0 eslint-plugin-node@^11.1.0 eslint-plugin-prettier@^4.0.0 eslint-plugin-promise@^6.0.0 eslint-plugin-react@^7.28.0 --save-dev

Usage

Add eda to the extends section of your configuration file (you can omit the eslint-config- prefix). This is a minimal .eslintrc.json file (it goes in the root of your project):

{
  "extends": "eda"
}

if your project includes react and JSX syntax, extend the react ruleset instead:

{
  "extends": "eda/react"
}

Easy fixing in VS Code

If you're using VS Code and want to fix linting and formatting errors painlessly install:

and add these lines to your settings.json

"editor.codeActionsOnSave": {
  "source.fixAll.eslint": true
},

"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
   "editor.defaultFormatter": "esbenp.prettier-vscode"
}

Now everytime you explicitly save the file (autosaving doesn't count), ESLint will fix as many errors as it can.

Tip: if you have syntax errors in the file, you'll need to fix them before your linting errors can be fixed for you.

Finding all errors in your project

These instructions assume that your source files are in folders in your project root called "server" and "client". Adjust accordingly

  1. Add "lint": "eslint client server" to the scripts section of your package.json file
  2. Add "format": "prettier -w client server" to the scripts section of your package.json file
  3. Add a .eslintignore file to the root of your project with these contents: bundle.js (and any other files/folders you want ESLint to ignore)

Now you simply run npm run lint to see all of the linting errors in your project.

Pro tip: Run npm run lint -- --fix to instruct ESLint to fix as many of the errors as it can, you can also run npm run format to correct the formatting of your source files.

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.