1.1.0 • Published 1 year ago

@progressivestudio/eslint-plugin v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@progressivestudio/eslint-plugin

License: MIT npm version

Shared ESLint rules and configs.

Installation

You'll first need to install ESLint:

With pnpm

pnpm add --dev eslint

With npm

$ npm i eslint --save-dev

Next, install @progressivestudio/eslint-plugin:

With pnpm

pnpm add --dev @progressivestudio/eslint-plugin

With npm

$ npm install @progressivestudio/eslint-plugin --save-dev

Usage

Shared ESLint configs come bundled in this package. In order to use them, you simply extend the relevant configuration in your project’s .eslintrc. For example, the following will extend the ESNext (ES2015 and later) config:

{
  "extends": "plugin:@progressivestudio/esnext"
}

If you are working on an ES5 project, extend the ES5 version of the configuration:

{
  "extends": "plugin:@progressivestudio/es5"
}

You can also add some "augmenting" configs on top of the "core" config by extending an array of linting configs. For example, the following configuration would provide a base ESNext config that is augmented by a React config:

{
  "extends": ["plugin:@progressivestudio/esnext", "plugin:@progressivestudio/react"]
}

Likewise, if you are using TypeScript and React, the following configuration extends the TypeScript base config with the React-specific rules provided by the React configuration file. To demonstrate multiple augmentations, we've also added the Prettier config, which disables rules that will conflict in projects using prettier.

{
  "extends": [
    "plugin:@progressivestudio/typescript",
    "plugin:@progressivestudio/react",
    "plugin:@progressivestudio/prettier"
  ]
}

Provided configurations

This plugin provides the following core configurations:

  • esnext: Use this for anything written with ES2015+ features.
  • typescript: Use this for Typescript projects. The rules enabled in this config do not require type-checking to run. To enable all Typescript rules, you must augment this config with the typescript-type-checking config mentioned below.
  • es5: Use this for legacy projects.

This plugin also provides the following tool-specific configurations, which can be used on top of the core configurations:

  • typescript-type-checking Use this config to augment the typescript config to enable all TypeScript rules, including those that require type checking. These rules are slower to run and and you will need to specify a path to your tsconfig.json file in the "project" property of "parserOptions". The following example would provide all of the TypeScript rules, assuming the tsconfig.json is in the same directory as you ESlint configuration.
{
  "extends": [
    "plugin:@progressivestudio/typescript",
    "plugin:@progressivestudio/typescript-type-checking"
  ],
  "parserOptions": {
    "project": "tsconfig.json"
  }
}
  • react: Use this for React projects.
  • prettier: Use prettier for consistent formatting. Extending this Shopify's prettier config will override the default Shopify eslint rules in favor of prettier formatting. Prettier must be installed within your project, as @progressivestudio/eslint-plugin does not provide the dependency itself.
  • webpack: Use this for projects built by webpack.

Supported Typescript version

The supported version of TypeScript is constrained by the @typescipt-eslint parser support that is installed.