Skip to content

Commit cb0db26

Browse files
authored
feat(plugin-stylelint):add plugin
2 parents e960ed3 + ebaedfa commit cb0db26

File tree

73 files changed

+5570
-1940
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+5570
-1940
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import tseslint from 'typescript-eslint';
2+
import baseConfig from '../../eslint.config.js';
3+
4+
export default tseslint.config(...baseConfig, {
5+
files: ['**/*.ts'],
6+
languageOptions: {
7+
parserOptions: {
8+
projectService: true,
9+
tsconfigRootDir: import.meta.dirname,
10+
},
11+
},
12+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["stylelint-config-standard"],
3+
"rules": {
4+
"color-no-invalid-hex": true,
5+
"declaration-colon-space-after": "always",
6+
"declaration-colon-space-before": "never",
7+
"indentation": 2,
8+
"declaration-block-trailing-semicolon": "always",
9+
"declaration-block-no-duplicate-properties": true,
10+
"block-opening-brace-space-before": "always",
11+
"string-quotes": "double",
12+
"max-line-length": 80,
13+
"no-eol-whitespace": true,
14+
"block-no-empty": true,
15+
"no-missing-end-of-source-newline": true,
16+
"declaration-block-no-redundant-longhand-properties": true
17+
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import stylelintPlugin from '@code-pushup/stylelint-plugin';
2+
import type { CoreConfig } from '@code-pushup/models';
3+
4+
export default {
5+
plugins: [
6+
await stylelintPlugin({
7+
stylelintrc: '.stylelintrc.json',
8+
patterns: ['**/*.css'],
9+
}),
10+
],
11+
} satisfies CoreConfig;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Additional CSS file for testing multiple file patterns */
2+
3+
.card {
4+
border: 1px solid #ccc;
5+
padding: 16px;
6+
margin: 8px;
7+
}
8+
9+
.card-header {
10+
font-weight: bold;
11+
margin-bottom: 8px;
12+
}
13+
14+
.card-body {
15+
line-height: 1.4;
16+
}
17+
18+
/* Valid CSS with no issues */
19+
.well-formatted {
20+
display: flex;
21+
flex-direction: column;
22+
gap: 12px;
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* CSS file in nested directory */
2+
3+
.nested-component {
4+
position: relative;
5+
z-index: 10;
6+
}
7+
8+
/* Issue: missing space after colon */
9+
.nested-issue {
10+
color: blue;
11+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* Mock CSS file with various stylelint issues for e2e testing */
2+
3+
/* Missing space after colon */
4+
.header {
5+
color: red;
6+
background-color: #ffffff;
7+
}
8+
9+
/* Inconsistent indentation */
10+
.navigation {
11+
padding: 10px;
12+
margin: 5px;
13+
}
14+
15+
/* Wrong unit usage */
16+
.footer {
17+
font-size: 14px;
18+
line-height: 1.5;
19+
margin: 0px; /* Should use 0 instead of 0px */
20+
}
21+
22+
/* Duplicate properties */
23+
.sidebar {
24+
width: 200px;
25+
width: 250px;
26+
height: 100%;
27+
}
28+
29+
/* Invalid hex color */
30+
.content {
31+
color: #fff;
32+
background: #12345;
33+
}
34+
35+
/* Unnecessary vendor prefixes */
36+
.button {
37+
-webkit-border-radius: 5px;
38+
-moz-border-radius: 5px;
39+
border-radius: 5px;
40+
}
41+
42+
/* Missing space before opening brace */
43+
.modal {
44+
position: fixed;
45+
top: 50%;
46+
}
47+
48+
/* Trailing whitespace and empty rules */
49+
.empty {
50+
}
51+
52+
/* Inconsistent quotes */
53+
.mixed-quotes {
54+
font-family: 'Arial', 'Helvetica', sans-serif;
55+
}
56+
57+
/* Long line that should be wrapped */
58+
.long-line {
59+
background: linear-gradient(
60+
to right,
61+
#ff0000,
62+
#00ff00,
63+
#0000ff,
64+
#ffff00,
65+
#ff00ff,
66+
#00ffff
67+
);
68+
}
69+
70+
/* Missing final newline */
71+
.last-rule {
72+
display: block;
73+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "plugin-stylelint-e2e",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "e2e/plugin-stylelint-e2e/src",
5+
"projectType": "application",
6+
"targets": {
7+
"lint": {},
8+
"e2e": {
9+
"executor": "@nx/vitest:test",
10+
"options": {
11+
"configFile": "{projectRoot}/vitest.e2e.config.ts"
12+
}
13+
}
14+
},
15+
"implicitDependencies": ["@code-pushup/plugin-stylelint"],
16+
"tags": ["scope:plugin", "type:e2e"]
17+
}

0 commit comments

Comments
 (0)