Skip to content

Commit

Permalink
trying stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
langermank committed Jun 20, 2023
1 parent 7cc4c08 commit c7a895a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions __tests__/no-deprecated-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ testRule({
true,
{
deprecatedFile: path.join(__dirname, '../plugins/lib/primitives-v8.json')
// inlineFallback: true
}
],
fix: true,
Expand Down Expand Up @@ -72,6 +73,13 @@ testRule({
code: '.x { border: 1px solid var(--color-neutral-emphasis); .foo { background-color: var(--color-neutral-emphasis); } }',
fixed:
'.x { border: 1px solid var(--borderColor-neutral-emphasis); .foo { background-color: var(--bgColor-neutral-emphasis); } }',
config: [
true,
{
deprecatedFile: path.join(__dirname, '../plugins/lib/primitives-v8.json'),
inlineFallback: false
}
],
warnings: [
{
message:
Expand Down
7 changes: 6 additions & 1 deletion plugins/no-deprecated-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const replacedVars = {}
const newVars = {}

module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, context) => {
const {inlineFallback = false} = options

if (!enabled) {
return noop
}
Expand Down Expand Up @@ -66,8 +68,11 @@ module.exports = stylelint.createPlugin(ruleName, (enabled, options = {}, contex
}
}

console.log('inlineFallback', inlineFallback)

Check failure on line 71 in plugins/no-deprecated-colors.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

if (context.fix && replacement !== null) {
replacement = `${replacement}`
// replacement = `${replacement}`
replacement = `${replacement}${inlineFallback ? `, var(${variableName})` : ''}`
replacedVars[variableName] = true
newVars[replacement] = true
if (node.type === 'atrule') {
Expand Down

0 comments on commit c7a895a

Please sign in to comment.