2.0.3 • Published 3 years ago

@mezzoforte/eslint-config-mezzoforte v2.0.3

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

eslint-config-mezzoforte

Shared ESLint config (for smaller or new projects).

Usage

yarn add -D eslint prettier eslint-plugin-jest @mezzoforte/eslint-config-mezzoforte@latest

.eslintrc.json:

{
  "extends": ["@mezzoforte/eslint-config-mezzoforte"],
  "parserOptions": {
    "project": "./tsconfig.json"
  }
}

After that you can customize your project specific "rules":{}. You might turn off rules that the project does not need.

IF you need to see the current used rules run:

npx eslint --ext .js,.jsx,.ts,.tsx --print-config [path-to-one-of-your-source-files].

prettier.config.js:

module.exports = require('@mezzoforte/eslint-config-mezzoforte/prettier.config');

Add to your .eslintignore or create it with:

prettier.config.js

package.json -scripts, for example:

  "lint": "eslint './src/**/*' --ext .js,.jsx,.ts,.tsx",
  "lint:nowarnings": "eslint --quiet './src/**/*' --ext .js,.jsx,.ts,.tsx",
  "lint:fix": "eslint --fix './src/**/*' --ext .js,.jsx,.ts,.tsx",
  "prettier": "prettier --list-different src/",
  "prettier:fix": "prettier --write src/",

Multiple dirs for ESLint ex. './{src,scripts}/**/*'

Husky and git-hooks

yarn add -D husky@4.3.8 git-format-staged npm-run-all

.huskyrc.js-example:

module.exports = {
  hooks: {
    'pre-commit':
      "git-format-staged -f 'prettier --ignore-unknown --stdin --stdin-filepath \"{}\"' '*.js' '*.jsx' '*.ts' '*.tsx'",
    'pre-push': 'npm-run-all lint test',
  },
};

React

If you are developing with React install:

yarn add -D eslint-config-react-app @typescript-eslint/eslint-plugin@^5.24.0 @typescript-eslint/parser@^5.24.0 babel-eslint@^10.0.0 eslint@^8.15.0 eslint-plugin-flowtype@^5.2.0 eslint-plugin-import@^2.26.0 eslint-plugin-jsx-a11y@^6.5.1 eslint-plugin-react@^7.29.4 eslint-plugin-react-hooks@^4.0.0

And then in your .eslintrc.jsonuse:

{
  "extends": ["react-app", "@mezzoforte/eslint-config-mezzoforte"]
}

Releases

Update 'package.json' version-field and run npm login (creds at 1password) then npm publish --access public