1.5.0 • Published 8 months ago

@encoura/eslint-config v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

ESLint Config

Encoura's preferred configs for TypeScript, Prettier, ESLint, CommitLint, and MarkdownLint.

Getting Started

Install this package, husky, and lint-staged as dev dependencies:

npm install --save-dev @encoura/eslint-config husky lint-staged

Configure husky by adding the following to your package.json file:

...
"scripts": {
  ...
  "prepare": "husky install",
  ...
},
...

Configure CommitLint

To configure CommitLint, create a commitlint.config.js file in the root of your project that contains the following:

module.exports = require('@encoura/eslint-config/commitlint.config');

This will allow CommitLint to discover the configuration this repository provides from within your node_modules folder.

By default the Encoura commitlint expects a commit message in the following format:

[XXX-###]: Subject where XXX-### is a jira ticket id, e.g., E4E-1

The commit message may also be in the form of git's standard merge commit format.

Configure ESLint

To configure ESLint, add the following to your .eslintrc.js and package.json files. This will allow ESLint to discover the configuration this repository provides from within your node_modules folder, and will check your *.js, *.ts, and *.tsx files for infractions every time you create a new commit:

module.exports = {
  extends: ['@encoura/eslint-config']
  ...
  // Add any custom rules/plugins/configuration here
}
...
"lint-staged": {
  ...
  "*.{js,ts,tsx}": "eslint",
  ...
},
...

Configure MarkdownLint

To configure MarkdownLint, add the following to your package.json file. This will allow MarkdownLint to discover the configuration this repository provides from within your node_modules folder, and will check your *.md files for infractions every time you create a new commit:

...
"lint-staged": {
  ...
  "*.{md}": "markdownlint --config node_modules/@encoura/eslint-config/markdownlint.config.json",
  ...
},
...

Configure Prettier

To configure prettier, create a .prettierrc.js file in the root of your project that contains the following:

module.exports = require('@encoura/eslint-config/.prettierrc');

This will allow Prettier to discover the configuration this repository provides from within your node_modules folder.

Next, add the following to your package.json file so that prettier will check your files for infractions every time you create a new commit:

...
"lint-staged": {
  ...
  "*.{js,json,md,ts,tsx}": [
    "prettier --write",
    "git add"
  ]
  ...
},
...

Configure Jest

To configure Jest, create a jest.config.js file in the root of your project that contains the following:

const defaultConfig = require('@encoura/eslint-config/jest.config');

module.export = {
  ...defaultConfig,
  // Extra project specific jest config here...
} 

This will allow Jest to discover the configuration this repository provides from within your node_modules folder.

Configure TypeScript

To configure TypeScript, add the following to your tsconfig.json file. This will allow TypeScript to discover the configuration this repository provides from within your node_modules folder:

...
"extends": "node_modules/@encoura/eslint-config/tsconfig.json",
...

Local Development

npm Scripts

There are several npm scripts at your disposal during local development. Here are some of the more important ones:

ScriptDescription
npm testRun all tests.
npm run releasePublish a new release of the ESLint Config.