1.2.0 • Published 3 years ago

@tavernard/eslint-config v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Eslint and Prettier Setup

These are my settings for ESLint and Prettier settings.

What it does

  • Lints Typescript based on the latest standards
  • Fixes issues and formatting errors with Prettier

Installing

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

  2. Then we need to install everything needed by the config:

npx install-peerdeps --dev @tavernard/eslint-config-tavernard
  1. You can see in your package.json there are now a big list of devDependencies.

  2. Add the following code to your package.json:

"eslintConfig": {
   "extends": [
      "@tavernard"
   ],
},
  1. Create a .eslintrc.js file in the root of your project's directory (it should live where package.json does). Your .eslintrc.js file should look like this:
module.exports = {
  "extends": [
    "@tavernard"
  ]
}
  1. You can add two scripts to your package.json to lint and/or fix:
"scripts": {
  "lint": "eslint .",
  "lint:fix": "eslint . --fix"
},

With VS Code

Once you have done. You probably want your editor to lint and fix for you.

  1. Install the ESLint package
  2. Now we need to setup some VS Code settings via Code/FilePreferencesSettings. Click to the {} icon in the top right corner and add this :
{
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

With Create React App

  1. You gotta eject first npm run eject or yarn eject
  2. Run npx install-peerdeps --dev @tavernard/eslint-config-tavernard
  3. Crack open your package.json and replace "extends": "react-app" with "extends": ["@tavernard/eslint-config-tavernard"]