@dialpad/stylelint-plugin-dialtone 1.0.1 → 1.1.0

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.
package/lib/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  const noMixins = require("./rules/no-mixins");
4
+ const recommendFontStyleTokens = require("./rules/recommend-font-style-tokens");
4
5
 
5
- module.exports = [noMixins];
6
+ module.exports = [noMixins, recommendFontStyleTokens];
@@ -0,0 +1,53 @@
1
+ const stylelint = require("stylelint");
2
+
3
+ const {
4
+ createPlugin,
5
+ utils: { report, ruleMessages, validateOptions },
6
+ } = stylelint;
7
+
8
+ const ruleName = '@dialpad/stylelint-plugin-dialtone/recommend-font-style-tokens';
9
+
10
+ const messages = ruleMessages(ruleName, {
11
+ recommendFontStyleTokens: (property) => `Instead of setting "${property}" it is
12
+ preferred to set the property Font to a composition token that bundles font-family, font-weight, font-size, and line-height.
13
+ More information can be found here:
14
+ https://dialtone.dialpad.com/design/typography/#api. There can be cases where using these selectors is intentional and valid,
15
+ in which case you can ignore this warning.`,
16
+ });
17
+
18
+ const meta = {
19
+ url: "https://github.com/dialpad/dialtone/blob/staging/packages/stylelint-plugin-dialtone/docs/rules/recommend-font-style-tokens.md",
20
+ };
21
+
22
+ /** @type {import('stylelint').Rule} */
23
+ const ruleFunction = (primary) => {
24
+ // reject setting font-size, font-family, font-weight, and line-height separately
25
+ return (root, result) => {
26
+ const validOptions = validateOptions(result, ruleName, {
27
+ actual: primary,
28
+ });
29
+
30
+ if (!validOptions) return;
31
+
32
+ // This iterates through one selector at a time, so you don't have to worry about checking for nested selectors.
33
+ root.walkDecls((declNode) => {
34
+ const typographyProperties = ['font-family', 'font-weight', 'font-size', 'line-height'];
35
+ if (typographyProperties.includes(declNode.prop)) {
36
+ report({
37
+ result,
38
+ ruleName,
39
+ node: declNode,
40
+ start: declNode.source.start,
41
+ end: declNode.source.end,
42
+ message: messages.recommendFontStyleTokens(declNode.prop),
43
+ });
44
+ }
45
+ });
46
+ };
47
+ };
48
+
49
+ ruleFunction.ruleName = ruleName;
50
+ ruleFunction.messages = messages;
51
+ ruleFunction.meta = meta;
52
+
53
+ module.exports = createPlugin(ruleName, ruleFunction);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dialpad/stylelint-plugin-dialtone",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "dialtone stylelint plugin",
5
5
  "keywords": [
6
6
  "Dialpad",
@@ -39,6 +39,9 @@
39
39
  },
40
40
  "license": "MIT",
41
41
  "main": "./lib/index.js",
42
+ "files": [
43
+ "lib"
44
+ ],
42
45
  "exports": "./lib/index.js",
43
46
  "devDependencies": {
44
47
  "stylelint": "15.11.0",
package/.eslintrc.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- root: true,
5
- extends: [
6
- "eslint:recommended",
7
- "plugin:eslint-plugin/recommended",
8
- "plugin:node/recommended",
9
- ],
10
- parserOptions: {
11
- ecmaVersion: 'latest',
12
- parser: "vue-eslint-parser"
13
- },
14
- env: {
15
- node: true,
16
- },
17
- };
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../.markdownlint.json"
3
- }
package/CHANGELOG.json DELETED
@@ -1 +0,0 @@
1
- {"versions":[{"version":"1.0.1","title":"[1.0.1](https://github.com/dialpad/dialtone/compare/stylelint-plugin-dialtone/v1.0.0...stylelint-plugin-dialtone/v1.0.1) (2024-03-20)","date":"2024-03-20","body":"### Bug Fixes\n\n* use mixin property to detect mixin ([#215](https://github.com/dialpad/dialtone/issues/215)) ([493f58e](https://github.com/dialpad/dialtone/commit/493f58ef37ea14392bfee0fabc7c0cf8fa524d2a))\n\n\n\n### Features\n\n* dialtone stylelint plugin - no mixins rule ([#186](https://github.com/dialpad/dialtone/issues/186)) ([8fe0ffb](https://github.com/dialpad/dialtone/commit/8fe0ffb7f4dd81cbf19e6cbbe37b16ca609973cd))","parsed":{"_":["use mixin property to detect mixin (#215) (493f58e)","dialtone stylelint plugin - no mixins rule (#186) (8fe0ffb)"],"Bug Fixes":["use mixin property to detect mixin (#215) (493f58e)"],"Features":["dialtone stylelint plugin - no mixins rule (#186) (8fe0ffb)"]}}],"title":"1.0.0 (2024-03-07)"}
package/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- ## [1.0.1](https://github.com/dialpad/dialtone/compare/stylelint-plugin-dialtone/v1.0.0...stylelint-plugin-dialtone/v1.0.1) (2024-03-20)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * use mixin property to detect mixin ([#215](https://github.com/dialpad/dialtone/issues/215)) ([493f58e](https://github.com/dialpad/dialtone/commit/493f58ef37ea14392bfee0fabc7c0cf8fa524d2a))
7
-
8
- # 1.0.0 (2024-03-07)
9
-
10
-
11
- ### Features
12
-
13
- * dialtone stylelint plugin - no mixins rule ([#186](https://github.com/dialpad/dialtone/issues/186)) ([8fe0ffb](https://github.com/dialpad/dialtone/commit/8fe0ffb7f4dd81cbf19e6cbbe37b16ca609973cd))
@@ -1,35 +0,0 @@
1
- # Detects usage of LESS mixins (no-mixins)
2
-
3
- LESS mixin usage is one of the primary causes of our extremely slow front end build performance. We are attempting to remove as many LESS mixins as possible and eventually transition to a more modern pure CSS approach.
4
-
5
- ## Rule Details
6
-
7
- This rule aims to detect and prevent usage of LESS mixins.
8
-
9
- Examples of **incorrect** code for this rule:
10
-
11
- Mixin usage:
12
-
13
- ```css
14
- .a {
15
- .aMixin();
16
- }
17
- ```
18
-
19
- Older style mixin syntax usage:
20
-
21
- ```css
22
- .a {
23
- .aMixin;
24
- }
25
- ```
26
-
27
- Examples of **correct** code for this rule:
28
-
29
- No mixins used.
30
-
31
- ```css
32
- .a {
33
- color: var(--dt-color-foreground-critical);
34
- }
35
- ```
package/project.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "name": "stylelint-plugin-dialtone",
3
- "targets": {
4
- "publish": {
5
- "executor": "nx:run-commands",
6
- "options": {
7
- "command": "pnpm publish --filter ./packages/stylelint-plugin-dialtone",
8
- "parallel": false
9
- }
10
- },
11
- "release-github": {
12
- "executor": "nx:run-commands",
13
- "options": {
14
- "command": "pnpm semantic-release-plus --extends ./packages/stylelint-plugin-dialtone/release-ci.config.cjs",
15
- "parallel": false
16
- }
17
- },
18
- "release-local": {
19
- "executor": "nx:run-commands",
20
- "options": {
21
- "command": "pnpm semantic-release-plus --no-ci --extends ./packages/stylelint-plugin-dialtone/release-local.config.cjs",
22
- "parallel": false
23
- }
24
- }
25
- }
26
- }
@@ -1,32 +0,0 @@
1
- const name = 'stylelint-plugin-dialtone';
2
- const srcRoot = `packages/${name}`;
3
-
4
- module.exports = {
5
- extends: 'release.config.base.js',
6
- pkgRoot: srcRoot,
7
- tagFormat: name + '/v${version}',
8
- commitPaths: [`${srcRoot}/*`],
9
- plugins: [
10
- ['@semantic-release/commit-analyzer', {
11
- preset: 'angular',
12
- releaseRules: [
13
- { type: 'refactor', release: 'patch' },
14
- ],
15
- }],
16
- ['@semantic-release/release-notes-generator', {
17
- config: '@dialpad/conventional-changelog-angular',
18
- }],
19
- '@semantic-release/github',
20
- ],
21
- branches: [
22
- 'production',
23
- {
24
- name: 'beta',
25
- prerelease: true,
26
- },
27
- {
28
- name: 'alpha',
29
- prerelease: true,
30
- },
31
- ],
32
- };
@@ -1,40 +0,0 @@
1
- const name = 'stylelint-plugin-dialtone';
2
- const srcRoot = `packages/${name}`;
3
-
4
- module.exports = {
5
- extends: 'release.config.base.js',
6
- pkgRoot: srcRoot,
7
- tagFormat: name + '/v${version}',
8
- commitPaths: [`${srcRoot}/*`],
9
- assets: [`${srcRoot}/CHANGELOG.md`, `${srcRoot}/CHANGELOG.json`, `${srcRoot}/package.json`],
10
- plugins: [
11
- ['@semantic-release/commit-analyzer', {
12
- preset: 'angular',
13
- releaseRules: [
14
- { type: 'refactor', release: 'patch' },
15
- ],
16
- }],
17
- ['@semantic-release/release-notes-generator', {
18
- config: '@dialpad/conventional-changelog-angular',
19
- }],
20
- ['@dialpad/semantic-release-changelog-json', { changelogFile: `${srcRoot}/CHANGELOG.md`, changelogJsonFile: `${srcRoot}/CHANGELOG.json` }],
21
- ['@semantic-release/changelog', { changelogFile: `${srcRoot}/CHANGELOG.md` }],
22
- ['@semantic-release/npm', { npmPublish: false }],
23
- ['@semantic-release/git', {
24
- /* eslint-disable-next-line no-template-curly-in-string */
25
- message: `chore(release): ${name}` +
26
- '/v${nextRelease.version}\n\n${nextRelease.notes}',
27
- }],
28
- ],
29
- branches: [
30
- 'staging',
31
- {
32
- name: 'beta',
33
- prerelease: true,
34
- },
35
- {
36
- name: 'alpha',
37
- prerelease: true,
38
- },
39
- ],
40
- };
@@ -1,51 +0,0 @@
1
- import { testRule } from 'stylelint-test-rule-node';
2
-
3
- import plugin from '../../../lib/rules/no-mixins.js';
4
-
5
- const {
6
- rule: { messages, ruleName },
7
- } = plugin;
8
-
9
- testRule({
10
- plugins: [plugin],
11
- ruleName,
12
- config: true,
13
- customSyntax: 'postcss-less',
14
-
15
- accept: [
16
- {
17
- code: '.a { color: red; }',
18
- description: 'simple class definition with no LESS mixin',
19
- },
20
- ],
21
-
22
- reject: [
23
- {
24
- code: `.a {
25
- .aMixin();
26
- }`,
27
- description: 'simple class definition containing a LESS mixin',
28
- message: messages.noMixinsRejected('aMixin'),
29
- },
30
- {
31
- code: `.a {
32
- .aMixin;
33
- }`,
34
- description: 'simple class definition containing the older syntax for LESS mixins',
35
- message: messages.noMixinsRejected('aMixin'),
36
- },
37
- {
38
- code: `.a {
39
- color: red;
40
- .aMixin;
41
- vertical-align: middle;
42
- .otherMixin();
43
- }`,
44
- description: 'multiple mixins in a class definition',
45
- warnings: [
46
- { message: messages.noMixinsRejected('aMixin') },
47
- { message: messages.noMixinsRejected('otherMixin') },
48
- ],
49
- },
50
- ],
51
- });