Shopify’s ESLint rules and configs.
You'll first need to install ESLint:
yarn add --dev eslint
$ npm i eslint --save-dev
yarn add --dev eslint-plugin-shopify
$ npm install eslint-plugin-shopify --save-dev
Note: If you installed ESLint globally (using the
-g flag) then you must also install
Shopify’s 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:
If using React, extend the React version of the configuration (which adds some React-specific rules to those in the ESNext config):
If working on an ES5 project, extend the ES5 version of the configuration:
You can also add some "augmenting" configs on top of the "core" config by extending an array of linting configs. For example, this package provides a lodash linting config, which can be added to the ESNext config with the following configuration file:
This plugin provides the following core configurations:
This plugin also provides the following tool-specific configurations, which can be used on top of the core configurations:
If you are working on a node module, we also provide the node configuration for you. Note that this configuration needs to be used in conjunction with one of the core configurations (either
esnext). If you plan to transpile your code using Babel, use the
A node project that will use Babel for transpilation would need the following ESLint config:
This plugin provides the following custom rules, which are included as appropriate in all core linting configs:
Stack.Itemwithout any custom props.
sectionedprops in Polaris components instead of wrapping all contents in a
const, and always appear at module scope.
The easiest way to add new rules is to use the ESLint Yeoman generator. Running
yo eslint:rule from the root of this project should add the required main file, docs, and test for your new rules. Make sure that these are all filled out and consistent with the other rules before merging. All tests can be run using