Skip to content

Commit

Permalink
Merge pull request #129 from lee-chase/partialFixIssue124
Browse files Browse the repository at this point in the history
Partial fix issue124
  • Loading branch information
lee-chase authored Jul 9, 2024
2 parents 5cf05c2 + cab5c63 commit 6c615ed
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Changelog

- Partial fix for #124 (enforceScopes: false)

## 3.0.0

- Released
- V3 release (ESM for Stylelint 16)

## 3.0.0-rc.11

- Chore: address ESLint warnings and errors

## 3.0.0-rc.10

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylelint-plugin-carbon-tokens",
"version": "3.0.0-rc.10",
"version": "3.0.0",
"description": "A stylelint plugin to support the use of carbon component tokens.",
"keywords": [
"stylelint",
Expand Down
50 changes: 44 additions & 6 deletions src/rules/motion-duration-use/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,38 +453,76 @@ testRule({
{
code: `.foo { transition: all 70ms; }`,
fixed: `.foo { transition: all $duration--fast-01; }`,
description: "v11 reject and fix literal duration matching token '70ms'",
description: "v10 reject and fix literal duration matching token '70ms'",
message: messages.rejectedTransition('transition', '70ms'),
},
{
code: `.foo { transition: all 110ms; }`,
fixed: `.foo { transition: all $duration--fast-02; }`,
description: "v11 reject and fix literal duration matching token '110ms'",
description: "v10 reject and fix literal duration matching token '110ms'",
message: messages.rejectedTransition('transition', '110ms'),
},
{
code: `.foo { transition: all 150ms; }`,
fixed: `.foo { transition: all $duration--moderate-01; }`,
description: "v11 reject and fix literal duration matching token '150ms'",
description: "v10 reject and fix literal duration matching token '150ms'",
message: messages.rejectedTransition('transition', '150ms'),
},
{
code: `.foo { transition: all 240ms; }`,
fixed: `.foo { transition: all $duration--moderate-02; }`,
description: "v11 reject and fix literal duration matching token '240ms'",
description: "v10 reject and fix literal duration matching token '240ms'",
message: messages.rejectedTransition('transition', '240ms'),
},
{
code: `.foo { transition: all 400ms; }`,
fixed: `.foo { transition: all $duration--slow-01; }`,
description: "v11 reject and fix literal duration matching token '400ms'",
description: "v10 reject and fix literal duration matching token '400ms'",
message: messages.rejectedTransition('transition', '400ms'),
},
{
code: `.foo { transition: all 700ms; }`,
fixed: `.foo { transition: all $duration--slow-02; }`,
description: "v11 reject and fix literal duration matching token '700ms'",
description: "v10 reject and fix literal duration matching token '700ms'",
message: messages.rejectedTransition('transition', '700ms'),
},
],
});

testRule({
plugins: [plugin],
ruleName,
customSyntax: 'postcss-scss',
fix: true,
config: true,
reject: [
{
code: `@use "@carbon/layout" as layout; .foo { transition: padding 400ms cubic-bezier(0.25, 0.8, 0.075, 1); }`,
fixed: `@use "@carbon/layout" as layout; .foo { transition: padding $duration-slow-01 cubic-bezier(0.25, 0.8, 0.075, 1); }`,
description: `v11 reject and fix 'motion-duration' but and add no prefix`,
message: messages.rejectedTransition('transition', '400ms'),
},
],
});

// testRule({
// plugins: [plugin],
// ruleName,
// customSyntax: 'postcss-scss',
// fix: true,
// config: [
// true,
// {
// enforceScopes: true,
// },
// ],
// enforceScopes: true,
// reject: [
// {
// code: `@use "@carbon/layout" as layout; @use "@carbon/motion"; .foo { transition: padding 400ms cubic-bezier(0.25, 0.8, 0.075, 1); }`,
// fixed: `@use "@carbon/layout" as layout; @use "@carbon/motion"; .foo { transition: padding motion.$duration-slow-01 cubic-bezier(0.25, 0.8, 0.075, 1); }`,
// description: `v11 reject and fix 'motion-duration' but and add no prefix`,
// message: messages.rejectedTransition('transition', '400ms'),
// },
// ],
// });
10 changes: 10 additions & 0 deletions src/rules/theme-use/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,16 @@ testRule({
// fixed:
// "@use '@carbon/theme' as carbon_theme; .foo { color: carbon_theme.$button-danger-active; }"
// },
],
});

testRule({
plugins: [plugin],
ruleName,
config: [true, { enforceScopes: true }],
customSyntax: 'postcss-scss',
fix: true,
reject: [
{
code: "@use '@carbon/layout'; @use '@carbon/theme' as carbon_theme; .foo { background-color: $active-danger; }",
description:
Expand Down
2 changes: 1 addition & 1 deletion src/utils/checkRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export default async function checkRule(

if (!options.enforceScopes && !localScopes.includes('')) {
// scopes are not being enforced allow no scope
localScopes.push('');
localScopes.unshift('');
}

// **** walk rules and check values
Expand Down

0 comments on commit 6c615ed

Please sign in to comment.