@sketch-hq/sketch-assistant-utils
Advanced tools
Comparing version 4.0.0 to 5.0.0-next.0
# @sketch-hq/sketch-assistant-utils | ||
## 5.0.0-next.0 | ||
### Major Changes | ||
- fe07f0b: Remove support for config level ignore options `ignoreNames` and `ignoreClasses` | ||
## 4.0.0 | ||
@@ -4,0 +10,0 @@ |
@@ -29,11 +29,3 @@ import Ajv from 'ajv'; | ||
declare const getRuleSeverity: (config: AssistantConfig, ruleName: string) => ViolationSeverity; | ||
/** | ||
* Determine a rule's ignore classes. | ||
*/ | ||
declare const getRuleIgnoreClasses: (config: AssistantConfig, ruleName: string) => string[]; | ||
/** | ||
* Determine a rule's ignore name patterns. | ||
*/ | ||
declare const getRuleIgnoreNamePathPatterns: (config: AssistantConfig, ruleName: string) => RegExp[]; | ||
export { getRuleConfig, getRuleOption, isRuleConfigured, isRuleActive, getRuleSeverity, isRuleConfigValid, getRuleIgnoreClasses, getRuleIgnoreNamePathPatterns, }; | ||
export { getRuleConfig, getRuleOption, isRuleConfigured, isRuleActive, getRuleSeverity, isRuleConfigValid, }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -67,34 +67,2 @@ "use strict"; | ||
exports.getRuleSeverity = getRuleSeverity; | ||
/** | ||
* Determine a rule's ignore classes. | ||
*/ | ||
const getRuleIgnoreClasses = (config, ruleName) => { | ||
const rawValues = getRuleOption(config, ruleName, 'ignoreClasses'); | ||
if (!Array.isArray(rawValues)) | ||
return []; | ||
const sanitizedValues = []; | ||
for (const value of rawValues) { | ||
if (typeof value === 'string') { | ||
sanitizedValues.push(value); | ||
} | ||
} | ||
return sanitizedValues; | ||
}; | ||
exports.getRuleIgnoreClasses = getRuleIgnoreClasses; | ||
/** | ||
* Determine a rule's ignore name patterns. | ||
*/ | ||
const getRuleIgnoreNamePathPatterns = (config, ruleName) => { | ||
const rawValues = getRuleOption(config, ruleName, 'ignoreNames'); | ||
if (!Array.isArray(rawValues)) | ||
return []; | ||
const sanitizedValues = []; | ||
for (const value of rawValues) { | ||
if (typeof value === 'string') { | ||
sanitizedValues.push(value); | ||
} | ||
} | ||
return sanitizedValues.map((value) => new RegExp(value)); | ||
}; | ||
exports.getRuleIgnoreNamePathPatterns = getRuleIgnoreNamePathPatterns; | ||
//# sourceMappingURL=index.js.map |
@@ -43,3 +43,3 @@ "use strict"; | ||
*/ | ||
const addReportsToViolations = (report, violations, assistant, rule, iterateParents) => { | ||
const addReportsToViolations = (report, violations, assistant, rule) => { | ||
if (Array.isArray(report) && report.length === 0) | ||
@@ -50,23 +50,3 @@ return; | ||
const severity = assistant_config_1.getRuleSeverity(config, ruleName); | ||
const classesToIgnore = assistant_config_1.getRuleIgnoreClasses(config, ruleName); | ||
const namesToIgnore = assistant_config_1.getRuleIgnoreNamePathPatterns(config, ruleName); | ||
violations.push(...(Array.isArray(report) ? report : [report]) | ||
// Filter out reports involving nodes with ignored `_class` props | ||
.filter((item) => { | ||
return item.node ? !classesToIgnore.includes(item.node._class) : true; | ||
}) | ||
// Filter out nodes with ignored name paths | ||
.filter((item) => { | ||
if (!item.node || namesToIgnore.length === 0) | ||
return true; | ||
const names = 'name' in item.node ? [item.node.name] : []; | ||
iterateParents(item.node, (parent) => { | ||
if (typeof parent === 'object' && 'name' in parent) { | ||
names.unshift(parent.name); | ||
} | ||
}); | ||
const namePath = `/${names.join('/')}`; | ||
return !namesToIgnore.map((regex) => regex.test(namePath)).includes(true); | ||
}) | ||
.map((item) => { | ||
violations.push(...(Array.isArray(report) ? report : [report]).map((item) => { | ||
var _a; | ||
@@ -155,3 +135,3 @@ return { | ||
report(items) { | ||
addReportsToViolations(items, violations, assistant, rule, iterateParents); | ||
addReportsToViolations(items, violations, assistant, rule); | ||
}, | ||
@@ -158,0 +138,0 @@ iterateCache: file_cache_1.createCacheIterator(cache, operation), |
@@ -29,11 +29,3 @@ import Ajv from 'ajv'; | ||
declare const getRuleSeverity: (config: AssistantConfig, ruleName: string) => ViolationSeverity; | ||
/** | ||
* Determine a rule's ignore classes. | ||
*/ | ||
declare const getRuleIgnoreClasses: (config: AssistantConfig, ruleName: string) => string[]; | ||
/** | ||
* Determine a rule's ignore name patterns. | ||
*/ | ||
declare const getRuleIgnoreNamePathPatterns: (config: AssistantConfig, ruleName: string) => RegExp[]; | ||
export { getRuleConfig, getRuleOption, isRuleConfigured, isRuleActive, getRuleSeverity, isRuleConfigValid, getRuleIgnoreClasses, getRuleIgnoreNamePathPatterns, }; | ||
export { getRuleConfig, getRuleOption, isRuleConfigured, isRuleActive, getRuleSeverity, isRuleConfigValid, }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -56,33 +56,3 @@ import Ajv from 'ajv'; | ||
}; | ||
/** | ||
* Determine a rule's ignore classes. | ||
*/ | ||
const getRuleIgnoreClasses = (config, ruleName) => { | ||
const rawValues = getRuleOption(config, ruleName, 'ignoreClasses'); | ||
if (!Array.isArray(rawValues)) | ||
return []; | ||
const sanitizedValues = []; | ||
for (const value of rawValues) { | ||
if (typeof value === 'string') { | ||
sanitizedValues.push(value); | ||
} | ||
} | ||
return sanitizedValues; | ||
}; | ||
/** | ||
* Determine a rule's ignore name patterns. | ||
*/ | ||
const getRuleIgnoreNamePathPatterns = (config, ruleName) => { | ||
const rawValues = getRuleOption(config, ruleName, 'ignoreNames'); | ||
if (!Array.isArray(rawValues)) | ||
return []; | ||
const sanitizedValues = []; | ||
for (const value of rawValues) { | ||
if (typeof value === 'string') { | ||
sanitizedValues.push(value); | ||
} | ||
} | ||
return sanitizedValues.map((value) => new RegExp(value)); | ||
}; | ||
export { getRuleConfig, getRuleOption, isRuleConfigured, isRuleActive, getRuleSeverity, isRuleConfigValid, getRuleIgnoreClasses, getRuleIgnoreNamePathPatterns, }; | ||
export { getRuleConfig, getRuleOption, isRuleConfigured, isRuleActive, getRuleSeverity, isRuleConfigValid, }; | ||
//# sourceMappingURL=index.js.map |
import mem from 'mem'; | ||
import { createCacheIterator } from '../file-cache'; | ||
import { getRuleOption, isRuleConfigValid, getRuleSeverity, getRuleIgnoreClasses, getRuleIgnoreNamePathPatterns, } from '../assistant-config'; | ||
import { getRuleOption, isRuleConfigValid, getRuleSeverity } from '../assistant-config'; | ||
import { nodeToObject, objectHash, objectsEqual } from '../object-utils'; | ||
@@ -31,3 +31,3 @@ import * as pointers from '../pointers'; | ||
*/ | ||
const addReportsToViolations = (report, violations, assistant, rule, iterateParents) => { | ||
const addReportsToViolations = (report, violations, assistant, rule) => { | ||
if (Array.isArray(report) && report.length === 0) | ||
@@ -38,23 +38,3 @@ return; | ||
const severity = getRuleSeverity(config, ruleName); | ||
const classesToIgnore = getRuleIgnoreClasses(config, ruleName); | ||
const namesToIgnore = getRuleIgnoreNamePathPatterns(config, ruleName); | ||
violations.push(...(Array.isArray(report) ? report : [report]) | ||
// Filter out reports involving nodes with ignored `_class` props | ||
.filter((item) => { | ||
return item.node ? !classesToIgnore.includes(item.node._class) : true; | ||
}) | ||
// Filter out nodes with ignored name paths | ||
.filter((item) => { | ||
if (!item.node || namesToIgnore.length === 0) | ||
return true; | ||
const names = 'name' in item.node ? [item.node.name] : []; | ||
iterateParents(item.node, (parent) => { | ||
if (typeof parent === 'object' && 'name' in parent) { | ||
names.unshift(parent.name); | ||
} | ||
}); | ||
const namePath = `/${names.join('/')}`; | ||
return !namesToIgnore.map((regex) => regex.test(namePath)).includes(true); | ||
}) | ||
.map((item) => { | ||
violations.push(...(Array.isArray(report) ? report : [report]).map((item) => { | ||
var _a; | ||
@@ -143,3 +123,3 @@ return { | ||
report(items) { | ||
addReportsToViolations(items, violations, assistant, rule, iterateParents); | ||
addReportsToViolations(items, violations, assistant, rule); | ||
}, | ||
@@ -146,0 +126,0 @@ iterateCache: createCacheIterator(cache, operation), |
{ | ||
"name": "@sketch-hq/sketch-assistant-utils", | ||
"version": "4.0.0", | ||
"version": "5.0.0-next.0", | ||
"module": "dist/esm/index", | ||
@@ -30,3 +30,3 @@ "main": "dist/cjs/index", | ||
"@json-schema-spec/json-pointer": "0.1.2", | ||
"@sketch-hq/sketch-assistant-types": "2.0.1", | ||
"@sketch-hq/sketch-assistant-types": "3.0.0-next.0", | ||
"ajv": "6.12.0", | ||
@@ -33,0 +33,0 @@ "humps": "2.0.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
159520
2139
2
+ Added@sketch-hq/sketch-assistant-types@3.0.0-next.0(transitive)
- Removed@sketch-hq/sketch-assistant-types@2.0.1(transitive)