eslint-plugin-wrapper
Advanced tools
Comparing version 0.0.2 to 0.0.3-0
30
index.js
@@ -129,3 +129,6 @@ class EslintPluginWrapper { | ||
/** Given a rule info, get the correct string reference for it in a config (i.e. must include this plugin's name prefix) */ | ||
/** | ||
* Given a rule info, get the correct string reference for it in a config (i.e. must include this plugin's name prefix) | ||
* @param {RuleInfo} info | ||
*/ | ||
configRuleReference(info) { | ||
@@ -183,6 +186,4 @@ return `${this.pluginName}/${info.pluginName}/${info.ruleName}` | ||
return Object.fromEntries( | ||
Object.entries(config.rules).map(([key, val]) => | ||
key.startsWith(pluginName) | ||
? [`${this.pluginName}/${key}`, val] | ||
: [key, val], | ||
Object.entries(config.rules).map(entry => | ||
this.prefixConfigRule(entry), | ||
), | ||
@@ -227,6 +228,4 @@ ) | ||
rules: Object.fromEntries( | ||
Object.entries(config.rules).map(([key, val]) => | ||
key.startsWith(pluginName) | ||
? [`${this.pluginName}/${key}`, val] | ||
: [key, val], | ||
Object.entries(config.rules).map(entry => | ||
this.prefixConfigRule(entry), | ||
), | ||
@@ -243,2 +242,9 @@ ), | ||
prefixConfigRule([key, val]) { | ||
const matchingPlugin = Object.keys(this.plugins).find(name => | ||
key.startsWith(`${name}/`), | ||
) | ||
return matchingPlugin ? [`${this.pluginName}/${key}`, val] : [key, val] | ||
} | ||
buildProcessors() { | ||
@@ -259,6 +265,8 @@ return Object.assign( | ||
/** @typedef {{pluginName: string; plugin: import('.').Plugin; ruleName: string; rule: import('eslint').Rule.RuleModule}} RuleInfo */ | ||
/** | ||
* For a dictionary of plugins and a function to get entries, build a dictionary of rules. | ||
* | ||
* @type {<T>(plugins: Record<string, import('.').Plugin>, getEntry: (opts: {pluginName: string; plugin: import('.').Plugin; ruleName: string; rule: import('eslint').Rule.RuleModule}) => [string, T]) => Record<string, T>} | ||
* @type {<T>(plugins: Record<string, import('.').Plugin>, getEntry: (opts: RuleInfo) => [string, T]) => Record<string, T>} | ||
*/ | ||
@@ -271,3 +279,3 @@ function ruleDict(plugins, getEntry) { | ||
Object.entries(plugin.rules || {}).map(([ruleName, rule]) => | ||
getEntry({pluginName, pluginName, ruleName, rule}), | ||
getEntry({pluginName, ruleName, rule}), | ||
), | ||
@@ -274,0 +282,0 @@ ), |
{ | ||
"name": "eslint-plugin-wrapper", | ||
"version": "0.0.2", | ||
"version": "0.0.3-0", | ||
"description": "Write project-specific rules, in your own eslint config file", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"lint": "eslint .", | ||
"test": "npm run lint" | ||
"test": "jest" | ||
}, | ||
@@ -16,0 +16,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25512
282