forked from codeclimate/codeclimate-eslint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint-patch.js
43 lines (34 loc) · 1.2 KB
/
eslint-patch.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
'use strict';
var meld = require('meld');
var docs = require('./docs');
var Config = require("eslint/lib/config");
var ConfigUpgrader = require('./config_upgrader');
var supportedPlugins = ['react', 'babel'];
module.exports = function patcher(eslint) {
meld.around(eslint.CLIEngine, 'loadPlugins', function(joinPoint) {
var pluginNames = joinPoint.args[0];
var filteredPluginNames = pluginNames.filter(function(pluginName) {
return supportedPlugins.indexOf(pluginName) >= 0;
});
return joinPoint.proceed(filteredPluginNames);
});
meld.around(eslint.CLIEngine, 'addPlugin', function() {
return;
});
// meld.around(eslint.CLIEngine.Config, 'loadPackage', function(joinPoint) {
// var filePath = joinPoint.args[0];
// if (filePath.match(/^eslint-config-airbnb.*/)) {
// return joinPoint.proceed();
// } else {
// return {};
// }
// });
const originalGetConfig = Config.prototype.getConfig;
Config.prototype.getConfig = function(filePath) {
const originalConfig = originalGetConfig.apply(this, [filePath]);
const configUpgrader = new ConfigUpgrader();
return configUpgrader.upgrade(originalConfig);
};
eslint.docs = docs;
return eslint;
};