@leroymerlin/eslint-config-leroymerlin

1.3.0 • Public • Published

eslint-config-leroymerlin

LeroyMerlin's ESLint config for Node.js apps

  • Requires Node.js >=14
  • Requires ESLint >=8

Using with Javascript apps

@leroymerlin/eslint-config-leroymerlin/node/javascript

Install & Usage

npm install --save-dev eslint prettier @leroymerlin/eslint-config-leroymerlin

Note: It recommends a use of the "engines" field of package.json. The "engines" field is used by node/no-unsupported-features/* rules.

package.json

{
  /*
    ...
  */

  "engines": {
    "node": "14"
  }
}

.eslintrc.js (An example)

'use strict';

module.exports = {
  root: true,
  extends: ['@leroymerlin/eslint-config-leroymerlin/node/javascript'],
  rules: {
    /*
      Add any additional rules here
    */
    'no-console': 'warn',
  },
};

Using with Typescript apps

@leroymerlin/eslint-config-leroymerlin/node/typescript

Install & Usage

npm install --save-dev eslint prettier @leroymerlin/eslint-config-leroymerlin @typescript-eslint/eslint-plugin

.eslintrc.js (An example)

'use strict';

module.exports = {
  root: true,
  parserOptions: {
    project: 'tsconfig.json',
  },
  extends: ['@leroymerlin/eslint-config-leroymerlin/node/typescript'],
  rules: {
    /*
      Add any additional rules here
    */
    'no-console': 'warn',
  },
};

Additional Configuration

Please, use it config with husky 🐶 and lint-staged 🚫💩

To use git-hooks, install required dependencies via npm:

npx husky-init && npm install \
&& npm install --save-dev lint-staged

.husky/pre-commit

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install lint-staged

lint-staged.config.js (Javascript apps)

'use strict';

module.exports = {
  '*.{js,json,md,y*ml}': ['prettier --write'],
  '*.js': ['eslint --cache --fix'],
};

lint-staged.config.js (Typescript apps)

const fs = require('fs');

function generateTSConfig(stagedFilenames) {
  const tsconfig = JSON.parse(fs.readFileSync('tsconfig.json', 'utf8'));
  tsconfig.include = stagedFilenames;
  fs.writeFileSync('tsconfig.lint.json', JSON.stringify(tsconfig));
  return 'tsc --noEmit --project tsconfig.lint.json';
}

module.exports = {
  '*.{js,ts,json,md,y*ml}': ['prettier --write'],
  '*.ts': ['eslint --cache --fix', generateTSConfig],
};

License

@leroymerlin/eslint-config-leroymerlin is MIT.

Readme

Keywords

Package Sidebar

Install

npm i @leroymerlin/eslint-config-leroymerlin

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

7.15 kB

Total Files

8

Last publish

Collaborators

  • mangaka585
  • mr_andrew_kirillov
  • madmxg