@dialpad/stylelint-plugin-dialtone 1.0.1

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/.eslintrc.js ADDED
@@ -0,0 +1,17 @@
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
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../.markdownlint.json"
3
+ }
package/CHANGELOG.json ADDED
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,13 @@
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))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Dialpad
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # stylelint-plugin-dialtone
2
+
3
+ Dialtone StyleLint plugin containing rules to help developers maintain dialtone recommended practices for CSS.
4
+
5
+ ## Installation
6
+
7
+ You'll first need to install [stylelint](https://stylelint.io/) into your project:
8
+
9
+ ```sh
10
+ npm install -D stylelint
11
+ ```
12
+
13
+ Next, install `@dialpad/stylelint-plugin-dialtone`:
14
+
15
+ ```sh
16
+ npm install -D @dialpad/stylelint-plugin-dialtone
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Add `@dialpad/stylelint-plugin-dialtone` to the plugins array in your stylelint.config file.
22
+
23
+ ```json
24
+ {
25
+ "plugins": ["@dialpad/stylelint-plugin-dialtone"],
26
+ }
27
+ ```
28
+
29
+ Then configure the rules you want to use under the rules section.
30
+
31
+ ```json
32
+ {
33
+ "rules": {
34
+ "@dialpad/stylelint-plugin-dialtone/no-mixins": true
35
+ }
36
+ }
37
+ ```
@@ -0,0 +1,35 @@
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/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ const noMixins = require("./rules/no-mixins");
4
+
5
+ module.exports = [noMixins];
@@ -0,0 +1,47 @@
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/no-mixins';
9
+
10
+ const messages = ruleMessages(ruleName, {
11
+ noMixinsRejected: (mixinName) => `Please avoid using LESS mixins "${mixinName}"`,
12
+ });
13
+
14
+ const meta = {
15
+ url: "https://github.com/dialpad/dialtone/blob/staging/packages/stylelint-plugin-dialtone/docs/rules/no-mixins.md",
16
+ };
17
+
18
+ /** @type {import('stylelint').Rule} */
19
+ const ruleFunction = (primary) => {
20
+ return (root, result) => {
21
+ const validOptions = validateOptions(result, ruleName, {
22
+ actual: primary,
23
+ });
24
+
25
+ if (!validOptions) return;
26
+
27
+ // This iterates through one selector at a time, so you don't have to worry about checking for nested selectors.
28
+ root.walkAtRules((ruleNode) => {
29
+ // docs for mixin property used here: https://github.com/shellscape/postcss-less?tab=readme-ov-file#mixins
30
+ if (!ruleNode.mixin) return;
31
+ report({
32
+ result,
33
+ ruleName,
34
+ node: ruleNode,
35
+ start: ruleNode.source.start,
36
+ end: ruleNode.source.end,
37
+ message: messages.noMixinsRejected(ruleNode.name),
38
+ });
39
+ });
40
+ };
41
+ };
42
+
43
+ ruleFunction.ruleName = ruleName;
44
+ ruleFunction.messages = messages;
45
+ ruleFunction.meta = meta;
46
+
47
+ module.exports = createPlugin(ruleName, ruleFunction);
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@dialpad/stylelint-plugin-dialtone",
3
+ "version": "1.0.1",
4
+ "description": "dialtone stylelint plugin",
5
+ "keywords": [
6
+ "Dialpad",
7
+ "Dialtone",
8
+ "stylelint"
9
+ ],
10
+ "contributors": [
11
+ {
12
+ "name": "Brad Paugh",
13
+ "email": "brad.paugh@dialpad.com",
14
+ "url": "https://github.com/braddialpad"
15
+ },
16
+ {
17
+ "name": "Francis Rupert",
18
+ "email": "francis.rupert@dialpad.com",
19
+ "url": "https://github.com/francisrupert"
20
+ },
21
+ {
22
+ "name": "Julio Ortega",
23
+ "email": "julio.ortega@dialpad.com",
24
+ "url": "https://github.com/juliodialpad"
25
+ },
26
+ {
27
+ "name": "Ignacio Ropolo",
28
+ "email": "ignacio.ropolo@dialpad.com",
29
+ "url": "https://github.com/iropolo"
30
+ },
31
+ {
32
+ "name": "Nina Repetto",
33
+ "email": "nina.repetto@dialpad.com",
34
+ "url": "https://github.com/ninamarina"
35
+ }
36
+ ],
37
+ "bugs": {
38
+ "email": "dialtone@dialpad.com"
39
+ },
40
+ "license": "MIT",
41
+ "main": "./lib/index.js",
42
+ "exports": "./lib/index.js",
43
+ "devDependencies": {
44
+ "stylelint": "15.11.0",
45
+ "stylelint-test-rule-node": "^0.2.1"
46
+ },
47
+ "engines": {
48
+ "node": ">= 18.0.0"
49
+ },
50
+ "peerDependencies": {
51
+ "stylelint": "^14.0.0 || ^15.0.0"
52
+ },
53
+ "scripts": {
54
+ "lint": "run-s lint:docs lint:code",
55
+ "lint:code": "eslint '**/*.js'",
56
+ "lint:docs": "markdownlint 'docs/**/*.md'",
57
+ "test": "node --test ./tests/lib/rules/*.mjs"
58
+ }
59
+ }
package/project.json ADDED
@@ -0,0 +1,26 @@
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
+ }
@@ -0,0 +1,32 @@
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
+ };
@@ -0,0 +1,40 @@
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
+ };
@@ -0,0 +1,51 @@
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
+ });