1.1.1 • Published 2 years ago

@hpi-schul-cloud/eslint-config v1.1.1

Weekly downloads
2
License
AGPL-3.0
Repository
github
Last release
2 years ago

@hpi-schul-cloud/eslint-config

This package contains shareable ESLint configuration used by the @hpi-schul-cloud applications.

npm (scoped)

Getting Started

1. Installation

Using npm:

  npm install @hpi-schul-cloud/eslint-config --save-dev

Using Yarn:

  yarn add @hpi-schul-cloud/eslint-config --dev

2. Usage

  • Create a new file and name it as .eslintrc.js
  • Import relevant config file from @hpi-schul-cloud/eslint-config and just export it as follows.

For JavaScript projects

module.exports = {
  extends: '@hpi-schul-cloud/eslint-config/javascript',
};

For Vue projects

module.exports = {
  extends: '@hpi-schul-cloud/eslint-config/javascriptVue',
};

For Jest tests

You should apply these rules only to your testfiles! Otherwise there will be a lot of false positives. It is recommended to use overrides for that.

module.exports = {
  // ... all your normal rules
  overrides: [
    {
      files: ["**/*.unit.js"], // regex that matches your testfiles
      extends: ["@hpi-schul-cloud/eslint-config/javascriptJest"],
    },
  ],
};

Override Default Config

If you want to override the default configuration, then add the following code in .eslintrc.js file:

Override config in JavaScript projects

module.exports = {
  extends: '@hpi-schul-cloud/eslint-config/javascript',
  // your config options goes here, e.g. plugins: [...], rules: { ... }
};

Override config in Vue projects

module.exports = {
  extends: '@hpi-schul-cloud/eslint-config/javascriptVue',
  // your config options goes here, e.g. plugins: [...], rules: { ... }
};

Override config in Jest tests

module.exports = {
  // ... all your normal rules
  overrides: [
    {
      files: ["**/*.unit.js"], // regex that matches your testfiles
      extends: ["@hpi-schul-cloud/eslint-config/javascriptJest"],
      rules: {
        // you can adjust the rules here.
      },
    },
  ],
};