eslint-plugin-itgalaxy
Version:
Itgalaxy org's ESLint rules and configs.
177 lines (129 loc) • 5.34 kB
Markdown
# eslint-plugin-itgalaxy
[](https://www.npmjs.org/package/eslint-plugin-itgalaxy)
[](https://travis-ci.org/itgalaxy/eslint-plugin-itgalaxy)
[](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy)
[](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy?type=dev)
[](https://david-dm.org/itgalaxy/eslint-plugin-itgalaxy?type=peer)
[](https://greenkeeper.io)
Itgalaxy’s ESLint rules and configs.
## Installation
You'll first need to install [ESLint](http://eslint.org):
```shell
$ npm i eslint --save-dev
```
Next, install `eslint-plugin-itgalaxy`:
```shell
$ npm install eslint-plugin-itgalaxy --save-dev
```
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-itgalaxy` globally.
**Note:** Some presets require additional dependencies (plugins).
Example `markdown` require `eslint-plugin-markdown` plugin.
So you need run:
```shell
$ npm install eslint-plugin-markdown --save-dev
```
By default all additional plugins listed in `peerDependencies` (this allows you to track non-compatibility with old versions), just ignore warnings if you don't need a plugin.
## Usage
Itgalaxy’s ESLint configs come bundled in this package. In order to use them, you simply extend the relevant configuration in your project’s `.eslintrc`.
**Configurations do not contain stylistic rules**, we use [prettier](https://github.com/prettier/prettier) for this purpose.
Better use `prettier` directly (using `npm` command), because it is allow to format `css`, `scss`, `markdown`, `json` and etc.
For example, the following will extend the ESNext (ES2015 and later) config:
```json
{
"extends": "plugin:itgalaxy/esnext"
}
```
If using React, extend the `React` version of the configuration (which adds some
React-specific rules to those in the ESNext config):
```json
{
"extends": ["plugin:itgalaxy/esnext", "plugin:itgalaxy/react"]
}
```
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:
```json
{
"extends": [
"plugin:itgalaxy/esnext",
"plugin:itgalaxy/react",
"plugin:itgalaxy/lodash",
"plugin:itgalaxy/jest"
]
}
```
Notice: presets **"plugin:itgalaxy/esnext"** should be **first**.
## Provided configurations
This plugin provides the following core configurations:
- [esnext](lib/config/esnext.js): Use this for anything written with ES2015+ features.
```json
{
"extends": ["plugin:itgalaxy/esnext"]
}
```
- [html](lib/config/html.js): Allow linting `JavaScript` in `HTML` (and `HTML` based) files (don't forget add `.html` to `--ext` CLI argument).
```json
{
"extends": ["plugin:itgalaxy/esnext", "plugin:itgalaxy/html"]
}
```
- [markdown](lib/config/markdown.js): Allow linting `JavaScript` in `markdown` files (don't forget add `.md` to `--ext` CLI argument).
Use this configuration:
```js
module.exports = {
extends: ["plugin:itgalaxy/esnext"],
overrides: [
{
files: ["**/*.md"],
parserOptions: {
ecmaFeatures: {
impliedStrict: true
}
},
rules: {
strict: "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-process-env": "off",
"no-process-exit": "off",
"no-console": "off",
"import/no-unresolved": "off",
"node/no-unpublished-require": "off"
}
}
]
};
```
- [node](lib/config/node.js): Use this for `nodejs` projects.
Example:
```json
{
"extends": ["plugin:itgalaxy/esnext", "plugin:itgalaxy/node"]
}
```
- [react](lib/config/react.js): Use this for `React` projects.
Example:
```json
{
"extends": ["plugin:itgalaxy/esnext", "plugin:itgalaxy/react"]
}
```
- [all](lib/config/all.js): Don't use. It is for internal purposes (testings and tools).
This plugin also provides the following tool-specific configurations, which can be used on top of the core configurations:
- [AVA](lib/config/ava.js): Use this for projects that use the
[AVA](https://github.com/sindresorhus/ava).
- [lodash](lib/config/lodash.js): Use this for projects that use
[lodash](https://lodash.com).
- [Jest](lib/config/jest.js): Use this for projects that use the
[Jest](https://github.com/facebook/jest).
## Creating New Rules
The easiest way to add new rules is to use the
[ESLint Yeoman generator](https://www.npmjs.com/package/generator-eslint).
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 `npm test`.
## [Changelog](CHANGELOG.md)
## [License](LICENSE)