-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
43 lines (37 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* eslint-env node */
'use strict';
var { requireUp } = require('./requireUp');
var { DEFAULT_EXTENSIONS } = require('./constants');
// First check for local rules in the current working directory and its ancestors (enables npm/yarn/pnpm workspaces support)
var rules = requireUp('eslint-local-rules', DEFAULT_EXTENSIONS, process.cwd());
if (!rules) {
// Then try the directory containing this plugin and its ancestors
rules = requireUp('eslint-local-rules', DEFAULT_EXTENSIONS, __dirname);
}
if (!rules) {
throw new Error(
'eslint-plugin-local-rules: ' +
'Cannot find "eslint-local-rules{' +
['.js'].concat(DEFAULT_EXTENSIONS.filter(Boolean)) +
'} ' +
'or eslint-local-rules/index.js (checked all ancestors of "' +
process.cwd() +
'" and "' +
__dirname +
'").'
);
}
var getConfig = (type) => ({
rules: Object.fromEntries(
Object
.keys(rules)
.map((rule) => [`local-rules/${rule}`, type])
),
});
module.exports = {
configs: {
all: getConfig('error'),
'all-warn': getConfig('warn'),
},
rules: rules,
};