@walgreenshealth/eslint-plugin

0.1.0 • Public • Published

@walgreenshealth/eslint-plugin

This plugin is mostly a set of configurations for ESLint. It consolidates a bunch of open source plugins and has a lot of rules.

It includes the following configs:

  • @walgreenshealth/recommended
  • @walgreenshealth/typescript
  • @walgreenshealth/storybook
  • @walgreenshealth/jest

And the following custom rules:

  • @walgreenshealth/custom-element-name makes sure name of a custom element declared in @customElement(walgreenshealth-whatever) matches its file name
  • @walgreenshealth/element-export-name makes sure the element's class name matches the file name
  • @walgreenshealth/no-for-each-in-tests Prefer Jest's test.each() over forEach()
  • @walgreenshealth/no-string-constructor discourages the use of String() to dodge type safety
  • @walgreenshealth/no-number-constructor discourages the use of Number() to dodge type safety

Here's a simple example of how to use it (.eslint.config.json):

const config = {
  plugins: ["@walgreenshealth/eslint-plugin"],
  extends: ["plugin:@walgreenshealth/recommended"],

  overrides: [
    {
      files: ["*.stories.js"],

      extends: [
        "plugin:@walgreenshealth/recommended",
        "plugin:@walgreenshealth/storybook",
      ],
    },
    {
      files: ["*.test.js"],

      extends: [
        "plugin:@walgreenshealth/recommended",
        "plugin:@walgreenshealth/storybook",
      ],
    },
  ],
};

/* eslint sonarjs/no-duplicate-string: "off" */

const typescriptParserOptions = {
  project: "tsconfig.eslint.json",
  tsconfigRootDir: __dirname,
};

module.exports = {
  parserOptions: {
    ecmaVersion: 2022,
    sourceType: "module",
  },

  extends: ["plugin:@walgreenshealth/recommended"],

  ignorePatterns: [
    "**/node_modules/**",
    "**/*.min.js",
    "**/dist/**",
    "**/coverage/**",
    "**/reports/**",
    "**/.stryker-tmp/**",
    "**/_templates/**",
    "stryker.conf.json",
  ],

  overrides: [
    {
      files: ["*.ts"],

      extends: [
        "plugin:@walgreenshealth/recommended",
        "plugin:@walgreenshealth/typescript",
      ],

      parserOptions: typescriptParserOptions,
    },

    {
      files: ["**/*.stories.ts"],

      extends: [
        "plugin:@walgreenshealth/recommended",
        "plugin:@walgreenshealth/typescript",
        "plugin:@walgreenshealth/storybook",
      ],

      parserOptions: typescriptParserOptions,
    },

    {
      files: ["**/*.test.ts"],

      extends: [
        "plugin:@walgreenshealth/recommended",
        "plugin:@walgreenshealth/typescript",
        "plugin:@walgreenshealth/jest",
      ],

      parserOptions: typescriptParserOptions,
    },
    {
      files: ["**/*.cjs"],

      parserOptions: {
        sourceType: "script",
      },

      env: {
        node: true,
      },

      extends: ["plugin:@walgreenshealth/recommended"],

      rules: {
        "import/no-commonjs": "off",

        "import/no-extraneous-dependencies": [
          "error",
          { devDependencies: true },
        ],
      },
    },
    {
      files: ["scripts/*.mjs"],

      parserOptions: {
        sourceType: "module",
      },

      env: {
        node: true,
      },

      extends: ["plugin:@walgreenshealth/recommended"],

      rules: {
        "no-console": "off",

        "import/no-extraneous-dependencies": [
          "error",
          { devDependencies: true },
        ],
      },
    },
  ],

  plugins: ["@walgreenshealth/eslint-plugin"],
};

Readme

Keywords

none

Package Sidebar

Install

npm i @walgreenshealth/eslint-plugin

Weekly Downloads

1

Version

0.1.0

License

ISC

Unpacked Size

30.1 kB

Total Files

22

Last publish

Collaborators

  • pmcelhaney