@primer/stylelint-config 12.7.1-rc.59e46db → 12.7.1-rc.bf11919

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,12 +3,12 @@ const matchAll = require('string.prototype.matchall')
3
3
 
4
4
  const ruleName = 'primer/no-deprecated-colors'
5
5
  const messages = stylelint.utils.ruleMessages(ruleName, {
6
- rejected: (varName, replacement) => {
6
+ rejected: (varName, replacement, property) => {
7
7
  if (replacement === null) {
8
- return `${varName} is a deprecated color variable. Please consult the primer color docs for a replacement. https://primer.style/primitives/storybook/?path=/story/migration-tables`
8
+ return `Variable ${varName} is deprecated for property ${property}. Please consult the primer color docs for a replacement. https://primer.style/primitives/storybook/?path=/story/migration-tables`
9
9
  }
10
10
 
11
- return `${varName} is a deprecated color variable. Please use the replacement ${replacement}.`
11
+ return `Variable ${varName} is deprecated for property ${property}. Please use the replacement ${replacement}.`
12
12
  }
13
13
  })
14
14
 
@@ -32,7 +32,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
32
32
  const seen = new WeakMap()
33
33
 
34
34
  // eslint-disable-next-line import/no-dynamic-require
35
- const variableChecks = require(options.deprecatedFile || '../__tests__/__fixtures__/primitives-v8.json')
35
+ const variableChecks = require(options.deprecatedFile || './lib/primitives-v8.json')
36
36
 
37
37
  const lintResult = (root, result) => {
38
38
  // Walk all declarations
@@ -55,10 +55,13 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
55
55
  if (variableName in variableChecks) {
56
56
  let replacement = variableChecks[variableName]
57
57
  if (typeof replacement === 'object') {
58
- for (const property of Object.keys(replacement)) {
59
- if (node.prop.includes(property)) {
60
- replacement = replacement[property]
61
- break
58
+ if (node.prop) {
59
+ for (const prop of replacement) {
60
+ // Check if node.prop starts with one of the props array elements
61
+ if (prop['props'].some(p => node.prop.startsWith(p))) {
62
+ replacement = prop['replacement']
63
+ break
64
+ }
62
65
  }
63
66
  }
64
67
  if (typeof replacement === 'object') {
@@ -79,7 +82,7 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
79
82
  }
80
83
 
81
84
  stylelint.utils.report({
82
- message: messages.rejected(variableName, replacement),
85
+ message: messages.rejected(variableName, replacement, node.prop),
83
86
  node,
84
87
  ruleName,
85
88
  result