diff --git a/CHANGELOG.md b/CHANGELOG.md index e05b8d1..2e8949c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index d20af41..c5545d6 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/rules/motion-duration-use/__tests__/index.js b/src/rules/motion-duration-use/__tests__/index.js index 6fada79..0f08098 100644 --- a/src/rules/motion-duration-use/__tests__/index.js +++ b/src/rules/motion-duration-use/__tests__/index.js @@ -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'), +// }, +// ], +// }); diff --git a/src/rules/theme-use/__tests__/index.js b/src/rules/theme-use/__tests__/index.js index dff046c..7a51ce9 100644 --- a/src/rules/theme-use/__tests__/index.js +++ b/src/rules/theme-use/__tests__/index.js @@ -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: diff --git a/src/utils/checkRule.js b/src/utils/checkRule.js index 31b52c8..c5d0d0a 100644 --- a/src/utils/checkRule.js +++ b/src/utils/checkRule.js @@ -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