eslint-plugin-lint
Advanced tools
Comparing version 0.0.1 to 1.0.0
@@ -10,8 +10,9 @@ 'use strict'; | ||
const seen = new Set(); | ||
const seen = Object.create(null); | ||
Object.defineProperty(module.exports, 'load', { | ||
value: function load(...targets) { | ||
value: function load() { | ||
const targets = Array.prototype.slice.call(arguments); | ||
targets.forEach(target => { | ||
if (!seen.has(target)) { | ||
if (!seen[target]) { | ||
fs.readdirSync(target) | ||
@@ -24,3 +25,3 @@ .filter(name => name.endsWith('.js')) | ||
}); | ||
seen.add(target); | ||
seen[target] = true; | ||
} | ||
@@ -27,0 +28,0 @@ }); |
{ | ||
"name": "eslint-plugin-lint", | ||
"version": "0.0.1", | ||
"description": "Load arbitrary ESLint rule into a single namespace", | ||
"version": "1.0.0", | ||
"description": "Load arbitrary ESLint rules into a single namespace", | ||
"keywords": [ | ||
@@ -21,3 +21,3 @@ "eslint", | ||
"eslint": "^4.0.0", | ||
"jest": "^22.2.1" | ||
"jest": "^21.0.0" | ||
}, | ||
@@ -24,0 +24,0 @@ "engines": { |
@@ -1,3 +0,56 @@ | ||
# eslint-plugin-lint | ||
# eslint-plugin-lint [![Build Status](https://travis-ci.org/zertosh/eslint-plugin-lint.svg?branch=master)](https://travis-ci.org/zertosh/eslint-plugin-lint) | ||
(TODO) | ||
Load arbitrary [ESLint](https://eslint.org/) rules from any number of directories, and use them under the `lint/` namespace. | ||
## Install | ||
```sh | ||
$ npm install eslint-plugin-lint --save-dev | ||
``` | ||
## Usage | ||
Consider a project with an `.eslintrc.js` at the root, and two directories with rules files: | ||
``` | ||
my-project | ||
├── .eslintrc.js | ||
├─┬ my-rules | ||
│ ├── no-foo.js | ||
│ └── no-bar.js | ||
└─┬ their-rules | ||
├── no-baz.js | ||
└── no-qux.js | ||
``` | ||
To make them available to ESLint, in the `.eslintrc.js` add: | ||
```js | ||
const path = require('path'); | ||
// (1) Require "eslint-plugin-lint", then call `load` with the | ||
// rules directories. | ||
require('eslint-plugin-lint').load( | ||
path.join(__dirname, 'my-rules'), // Tip: Use an absolute path to | ||
path.join(__dirname, 'their-rules') // avoid cwd resolution issues. | ||
); | ||
module.exports { | ||
plugins: [ | ||
'lint' // (2) Add the "eslint-plugin-lint" package as a plugin. | ||
], | ||
rules: { | ||
'lint/no-foo': 1, // (3) Declare the rules options with the "lint/" | ||
'lint/no-bar': 1, // prefix, plus the rule file name without ".js". | ||
'lint/no-baz': 1, | ||
'lint/no-qux': 1 | ||
} | ||
}; | ||
``` | ||
Now the rules are available like any other as `lint/no-foo`, `lint/no-ba`, and so on. | ||
## Prior Art | ||
* [`not-an-aardvark/eslint-plugin-rulesdir`](https://github.com/cletusw/not-an-aardvark/eslint-plugin-rulesdir) | ||
* [`eslint-plugin-local-rules`](https://github.com/cletusw/eslint-plugin-local-rules) |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4132
27
1
57