-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into releases/v1
- Loading branch information
Showing
10 changed files
with
4,728 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ jobs: | |
|
||
- run: npm ci | ||
|
||
- run: npm run lint | ||
|
||
- run: npm test | ||
|
||
- run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { problemMatcher } from "../.github/stylelint-problem-matcher.json"; | ||
|
||
export interface ProblemMatcher { | ||
owner: string; | ||
pattern: ProblemMatcherPattern[]; | ||
}; | ||
|
||
export interface ProblemMatcherPattern { | ||
regexp: string; | ||
file?: number; | ||
line?: number; | ||
column?: number; | ||
message?: number; | ||
code?: number; | ||
loop?: boolean; | ||
} | ||
|
||
export const stylelintMatcher: ProblemMatcher = problemMatcher[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export function matchResults(report: string[], regexp: RegExp): RegExpExecArray[] { | ||
return report.map(line => regexp.exec(line)) | ||
.filter(match => match); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { matchResults } from "../__helpers__/utils"; | ||
import { stylelintMatcher, ProblemMatcherPattern } from "../__data__/stylelintMatcher"; | ||
|
||
describe("problemMatcher", () => { | ||
it("has two patterns", () => { | ||
expect(stylelintMatcher.pattern.length).toEqual(2); | ||
}); | ||
|
||
describe("file pattern", () => { | ||
let pattern: ProblemMatcherPattern; | ||
let regexp: RegExp; | ||
|
||
beforeEach(() => { | ||
pattern = stylelintMatcher.pattern[0]; | ||
regexp = new RegExp(pattern.regexp); | ||
}); | ||
|
||
it("matches file path", () => { | ||
const reportOutput = [ | ||
"scss/_test.scss", | ||
" 11:16 × Unexpected unit length-zero-no-unit", | ||
" 11:28 × Unexpected unit length-zero-no-unit", | ||
]; | ||
|
||
const results = matchResults(reportOutput, regexp); | ||
|
||
expect(results.length).toEqual(1); | ||
expect(results[0][pattern.file]).toEqual("scss/_test.scss"); | ||
}); | ||
}); | ||
|
||
describe("violation pattern", () => { | ||
let pattern: ProblemMatcherPattern; | ||
let regexp: RegExp; | ||
|
||
beforeEach(() => { | ||
pattern = stylelintMatcher.pattern[1]; | ||
regexp = new RegExp(pattern.regexp); | ||
}); | ||
|
||
it("matches violations", () => { | ||
const reportOutput = [ | ||
"scss/_test.scss", | ||
" 11:16 × Unexpected unit length-zero-no-unit", | ||
" 11:28 × Unexpected unit length-zero-no-unit", | ||
]; | ||
|
||
const results = matchResults(reportOutput, regexp); | ||
|
||
expect(results.length).toEqual(2); | ||
}); | ||
|
||
it("matches violations without line numbers", () => { | ||
const reportOutput = [ | ||
"scss/_test.scss", | ||
" × Unexpected Unicode BOM unicode-bom", | ||
" 11:16 × Unexpected unit length-zero-no-unit", | ||
" 11:28 × Unexpected unit length-zero-no-unit", | ||
]; | ||
|
||
const results = matchResults(reportOutput, regexp); | ||
|
||
expect(results.length).toEqual(3); | ||
}); | ||
|
||
it("matches violation details", () => { | ||
const reportOutput = [ | ||
"scss/_test.scss", | ||
" 11:16 × Unexpected unit length-zero-no-unit", | ||
]; | ||
|
||
const results = matchResults(reportOutput, regexp); | ||
|
||
expect(results.length).toEqual(1); | ||
expect(results[0][pattern.line]).toEqual("11"); | ||
expect(results[0][pattern.column]).toEqual("16"); | ||
expect(results[0][pattern.message]).toEqual("Unexpected unit "); | ||
expect(results[0][pattern.code]).toEqual("length-zero-no-unit"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = { | ||
clearMocks: true, | ||
collectCoverage: true, | ||
collectCoverageFrom: [ | ||
"**/*.ts", | ||
"!dist/**", | ||
"!lib/**", | ||
"!**/node_modules/**", | ||
], | ||
coverageDirectory: "./coverage/", | ||
globals: { | ||
"ts-jest": { | ||
diagnostics: false, | ||
} | ||
}, | ||
moduleFileExtensions: ["js", "ts"], | ||
testEnvironment: "node", | ||
testMatch: ["**/*.test.ts"], | ||
testRunner: "jest-circus/runner", | ||
transform: { | ||
"^.+\\.ts$": "ts-jest", | ||
}, | ||
verbose: true, | ||
}; | ||
|
||
const processStdoutWrite = process.stdout.write.bind(process.stdout); | ||
|
||
process.stdout.write = (str, encoding, cb) => { | ||
if (!str.match(/^::/)) { | ||
return processStdoutWrite(str, encoding, cb); | ||
} | ||
}; |
Oops, something went wrong.