@episerver/eslint-plugin-cms

2.1.1 • Public • Published

NPM version Build status

@episerver/eslint-plugin-cms

Makes sure only public non-deprecated Episerver CMS API's are used.

If you work on multiple Episerver projects and want to help us improve our public API, we could use your help.

Screenshot of summary output

Installation

First, install ESLint:

$ npm i eslint --save-dev
# or
$ yarn add eslint -D

Next, install @episerver/eslint-plugin-cms:

$ npm i @episerver/eslint-plugin-cms --save-dev
# or
$ yarn add @episerver/eslint-plugin-cms -D

Note: If you installed ESLint globally (using the -g flag) then you must also install @episerver/eslint-plugin-cms globally.

Usage

Add @episerver/eslint-plugin-cms to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "@episerver/cms"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "@episerver/cms/no-internal-episerver-apis": "error",
        "@episerver/cms/no-deprecated-episerver-apis": "warn"
    }
}

Recommended config

This plugin exports a recommended config that enforces good practices.

Enable it in your .eslintrc.json with the extends option:

{
    "extends": "plugin:@episerver/cms/recommended"
}

Analyzing multiple projects

Install globally (see instructions above), and then run this for any project:

$ eslint C:/YourEpiserverProject/ --output-file=YourEpiserverProject.json --plugin=episerver-cms --format=episerver-cms --ignore-pattern="node_modules" --ignore-pattern="dtk" --rule="{ \"@episerver/cms/no-internal-episerver-apis\": error, \"@episerver/cms/no-deprecated-episerver-apis\": warn }"

Supported Rules

Formatters

There are several formatters you can use to get a clearer overview of what Episerver API's are being used but shouldn't be. They are installed separately, with @episerver/eslint-formatter-cms.

$ npm i @episerver/eslint-formatter-cms --save-dev
# or
$ yarn add @episerver/eslint-formatter-cms -D

Then you can get a summary view with:

$ eslint . --format=episerver-cms

Package Sidebar

Install

npm i @episerver/eslint-plugin-cms

Weekly Downloads

8

Version

2.1.1

License

Apache-2.0

Unpacked Size

135 kB

Total Files

17

Last publish

Collaborators

  • johanpetersson
  • ryanbare
  • barteksekula
  • alwa
  • robinjac