Skip to content

Commit 15d8f52

Browse files
authored
improve stylelint textRange reporting
1 parent 52c517b commit 15d8f52

File tree

4 files changed

+46
-26
lines changed

4 files changed

+46
-26
lines changed

cli/helpers/lint-stream.mjs

+14-10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export async function run(options) {
3131
"**/*.git*/**",
3232
"**/*node_modules/**",
3333
"**/*build/**",
34+
"**/*reports/ut-coverage/**",
3435
"**/*dist/**",
3536
"**/*lcov-report/**",
3637
"**/*.min.js",
@@ -134,24 +135,27 @@ export async function run(options) {
134135
}
135136

136137
for (const issue of issues) {
137-
formattedResults.push({
138+
const chunk = {
138139
ruleId: issue.ruleId || "formatting",
139140
engineId: issue.engineId,
140141
severity: ["INFO", "MINOR", "CRITICAL", "BLOCKER"][issue.severity],
141142
type: issue.severity > 1 ? "BUG" : "CODE_SMELL",
142143
primaryLocation: {
143144
message: issue.message,
144145
filePath: filePath,
145-
textRange: issue.line
146-
? {
147-
startLine: issue.line,
148-
endLine: issue.endLine,
149-
startColumn: issue.column - 1,
150-
endColumn: issue.endColumn - 1,
151-
}
152-
: undefined,
153146
},
154-
});
147+
};
148+
149+
if (issue.line) {
150+
chunk.primaryLocation.textRange = { startLine: issue.line };
151+
if (issue.endLine !== undefined && issue.column !== undefined && issue.endColumn !== undefined) {
152+
chunk.primaryLocation.textRange.startColumn = issue.column;
153+
chunk.primaryLocation.textRange.endColumn = issue.endColumn;
154+
chunk.primaryLocation.textRange.endLine = issue.endLine;
155+
}
156+
}
157+
158+
formattedResults.push(chunk);
155159
}
156160
}
157161

cli/helpers/stylelint.mjs

+30-14
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,38 @@ export async function createEngine(options) {
8888
}
8989

9090
info.issues.push(
91-
...results.parseErrors.map((item) => ({
92-
engineId: "stylelint",
93-
message: item.text,
94-
ruleId: item.rule,
95-
...item,
96-
severity: 2,
97-
})),
91+
...results.parseErrors.map((item) => {
92+
const chunk = Object.assign({
93+
engineId: "stylelint",
94+
message: item.text,
95+
ruleId: item.rule,
96+
}, item);
97+
98+
delete chunk.column;
99+
delete chunk.endLine;
100+
delete chunk.endColumn;
101+
102+
chunk.severity = 2;
103+
104+
return chunk;
105+
}),
98106
);
99107
info.issues.push(
100-
...results.warnings.map((item) => ({
101-
engineId: "stylelint",
102-
message: item.text,
103-
ruleId: item.rule,
104-
...item,
105-
severity: 1,
106-
})),
108+
...results.warnings.map((item) => {
109+
const chunk = Object.assign({
110+
engineId: "stylelint",
111+
message: item.text,
112+
ruleId: item.rule,
113+
}, item);
114+
115+
delete chunk.column;
116+
delete chunk.endLine;
117+
delete chunk.endColumn;
118+
119+
chunk.severity = 1;
120+
121+
return chunk;
122+
}),
107123
);
108124
} catch (error) {
109125
info.issues.push({

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lastui/rocker",
3-
"version": "0.20.40",
3+
"version": "0.20.41",
44
"license": "Apache-2.0",
55
"author": "[email protected]",
66
"homepage": "https://github.com/lastui/rocker#readme",

webpack/config/module/production.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ module.exports = merge(require("../../internal/base.js"), require("../../interna
119119
type: "asset/source",
120120
},
121121
{
122-
test: /\.(mp3|png|jpe?g|gif|ico)$/i,
122+
test: /\.(mp3|png|jpe?g|gif|ico|svg)$/i,
123123
dependency: { not: ["url"] },
124124
type: "asset/inline",
125125
},

0 commit comments

Comments
 (0)