Skip to content

Commit 9d4e9a5

Browse files
committed
Initial commit
0 parents  commit 9d4e9a5

File tree

5 files changed

+182
-0
lines changed

5 files changed

+182
-0
lines changed

.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
33+
# Optional npm cache directory
34+
.npm
35+
36+
# Optional REPL history
37+
.node_repl_history

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Clayton Watts
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# eslint-plugin-local-rules
2+
A plugin for ESLint that allows you to use project-specific rules, similar to the [`--rulesdir`](http://eslint.org/docs/user-guide/command-line-interface#--rulesdir) command line option ([more](http://eslint.org/docs/developer-guide/working-with-rules#runtime-rules)).
3+
4+
Workaround for https://github.com/eslint/eslint/issues/2715
5+
6+
7+
## Dependencies
8+
9+
* Requires ESLint version 0.8.0 or higher
10+
11+
12+
## Install
13+
14+
```
15+
npm install eslint-plugin-local-rules
16+
```
17+
18+
19+
## Usage
20+
21+
### ./eslint-local-rules.js
22+
23+
```javascript
24+
'use strict';
25+
26+
module.exports = {
27+
'disallow-identifiers': {
28+
meta: {
29+
docs: {
30+
description: 'disallow identifiers',
31+
category: 'Possible Errors',
32+
recommended: false,
33+
},
34+
schema: [],
35+
},
36+
create: function(context) {
37+
return {
38+
Identifier: function(node) {
39+
context.report({
40+
node: node,
41+
message: 'Identifiers not allowed for Super Important reasons.',
42+
});
43+
},
44+
};
45+
},
46+
},
47+
};
48+
```
49+
50+
### ./.eslintrc
51+
52+
```json
53+
{
54+
"plugins": [
55+
"eslint-plugin-local-rules"
56+
],
57+
58+
"rules": {
59+
"local-rules/disallow-identifiers": 2
60+
}
61+
}
62+
```
63+
64+
65+
## License
66+
67+
MIT

index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* eslint-env node */
2+
'use strict';
3+
4+
var path = require('path');
5+
6+
var rules = requireUp('eslint-local-rules.js');
7+
8+
module.exports = {
9+
rules: rules,
10+
};
11+
12+
// Attempt to require a file, recursively checking parent directories until found
13+
// Similar to native `require` behavior, but doesn't check in `node_modules` folders
14+
// Based on https://github.com/js-cli/node-findup-sync
15+
function requireUp(filename, cwd) {
16+
cwd = cwd || process.cwd();
17+
var filepath = path.resolve(cwd, filename);
18+
19+
try {
20+
return require(filepath);
21+
} catch(error) {
22+
// Ignore (will recurse to parent directory)
23+
}
24+
25+
var dir = path.dirname(cwd);
26+
if (dir === cwd) {
27+
return undefined;
28+
}
29+
30+
return requireUp(filename, dir);
31+
}

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "eslint-plugin-local-rules",
3+
"version": "0.0.1",
4+
"description": "A plugin for ESLint that allows you to use project-specific rules",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/cletusw/eslint-plugin-local-rules.git"
12+
},
13+
"keywords": [
14+
"eslint",
15+
"eslintplugin"
16+
],
17+
"author": "Clayton Watts <cletusw@gmail.com> (https://github.com/cletusw)",
18+
"license": "MIT",
19+
"bugs": {
20+
"url": "https://github.com/cletusw/eslint-plugin-local-rules/issues"
21+
},
22+
"homepage": "https://github.com/cletusw/eslint-plugin-local-rules#readme",
23+
"peerDependencies": {
24+
"eslint": ">=0.8.0"
25+
}
26+
}

0 commit comments

Comments
 (0)