-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enhance] | make eslint default extention and render extendible 'styl…
…elint' via file precision (#28)
- Loading branch information
Showing
17 changed files
with
971 additions
and
279 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: CI | ||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20.x" | ||
- run: npm ci | ||
- name: Test linters | ||
run: npm run test |
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 |
---|---|---|
|
@@ -15,4 +15,5 @@ Dockerfile | |
*.ico | ||
!.prettierrc.js | ||
*/env.d.ts | ||
eslint.config.mjs | ||
eslint.config.mjs | ||
**/*.js |
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,3 @@ | ||
export default { | ||
extends: "./stylelint/index.js", | ||
}; |
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,5 @@ | ||
<style> | ||
tag { | ||
color: #0000; | ||
} | ||
</style> |
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,14 @@ | ||
<style scoped> | ||
a { | ||
color: v-bind(color); | ||
} | ||
:global(.foo), | ||
::v-deep(.foo), | ||
::v-slotted(.foo), | ||
::v-global(.foo), | ||
:deep(.foo), | ||
:slotted(.foo) { | ||
color: red; | ||
} | ||
</style> |
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,3 @@ | ||
p { | ||
text-align: center; | ||
} |
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,164 @@ | ||
import { beforeEach, describe, it } from "node:test"; | ||
import assert from "node:assert/strict"; | ||
import { readFileSync } from "node:fs"; | ||
|
||
import stylelint from "stylelint"; | ||
|
||
import config from "../../stylelint/index.js"; | ||
|
||
describe("With css file", () => { | ||
const validCss = readFileSync("./__tests__/stylelint/validCss.css", "utf-8"); | ||
const invalidCss = readFileSync( | ||
"./__tests__/stylelint/invalidCss.css", | ||
"utf-8", | ||
); | ||
|
||
describe("flags no warnings with valid css", () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: validCss, | ||
config, | ||
}); | ||
}); | ||
|
||
it("has no errors", () => { | ||
assert.equal(result.errored, false); | ||
}); | ||
|
||
it("flags no warnings", () => { | ||
assert.equal(result.results[0].warnings.length, 0); | ||
}); | ||
}); | ||
|
||
describe("flags warnings with invalid css", () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidCss, | ||
config, | ||
}); | ||
}); | ||
|
||
it("includes an error", () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it("flags one warning", () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it("corrects warning text", () => { | ||
assert.equal( | ||
result.results[0].warnings[0].text, | ||
'Unexpected unknown type selector "madeup" (selector-type-no-unknown)', | ||
); | ||
}); | ||
|
||
it("corrects rule flagged", () => { | ||
assert.equal( | ||
result.results[0].warnings[0].rule, | ||
"selector-type-no-unknown", | ||
); | ||
}); | ||
|
||
it("corrects severity flagged", () => { | ||
assert.equal(result.results[0].warnings[0].severity, "error"); | ||
}); | ||
|
||
it("corrects line number", () => { | ||
assert.equal(result.results[0].warnings[0].line, 1); | ||
}); | ||
|
||
it("corrects column number", () => { | ||
assert.equal(result.results[0].warnings[0].column, 1); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("With css inside vue file", () => { | ||
const validVueCss = readFileSync( | ||
"./__tests__/stylelint/TheValid.vue", | ||
"utf-8", | ||
); | ||
const invalidVueCss = readFileSync("./__tests__/stylelint/TheInvalid.vue", "utf-8"); | ||
|
||
describe("flags no warnings with valid css", () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: validVueCss, | ||
config, | ||
}); | ||
}); | ||
|
||
|
||
it("flags one warnings", () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
assert.equal(result.results[0].warnings[0].rule, "CssSyntaxError"); | ||
assert.equal(result.results[0].warnings[0].text, "Unknown word (CssSyntaxError)"); | ||
}); | ||
}); | ||
|
||
describe("flags warnings with invalid css", () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidVueCss, | ||
config, | ||
}); | ||
}); | ||
|
||
it("includes an error", () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it("flags one warning", () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it("corrects warning text", () => { | ||
console.log(result.results[0].warnings[0].text); | ||
assert.equal( | ||
result.results[0].warnings[0].text, | ||
"Unknown word (CssSyntaxError)", | ||
); | ||
}); | ||
|
||
it("corrects rule flagged", () => { | ||
assert.equal(result.results[0].warnings[0].rule, "CssSyntaxError"); | ||
}); | ||
|
||
it("corrects severity flagged", () => { | ||
assert.equal(result.results[0].warnings[0].severity, "error"); | ||
}); | ||
|
||
it("corrects line number", () => { | ||
assert.equal(result.results[0].warnings[0].line, 5); | ||
}); | ||
|
||
it("corrects column number", () => { | ||
assert.equal(result.results[0].warnings[0].column, 1); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("deprecated rules are excluded", () => { | ||
const ruleNames = Object.keys(config.rules); | ||
|
||
it("is not empty", () => { | ||
assert.ok(ruleNames.length > 0); | ||
}); | ||
|
||
for (const ruleName of ruleNames) { | ||
it(`${ruleName}`, async () => { | ||
const rule = await stylelint.rules[ruleName]; | ||
|
||
assert.ok(!rule.meta.deprecated); | ||
}); | ||
} | ||
}); |
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,3 @@ | ||
madeup { | ||
top: 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,10 @@ | ||
@import url("./importedCss.css"); | ||
|
||
.selector-1, | ||
.selector-2, | ||
.selector-3[type="text"] { | ||
background: linear-gradient(#fff, rgba(0, 0, 0, 0.8)); | ||
box-sizing: border-box; | ||
display: block; | ||
color: #333; | ||
} |
Oops, something went wrong.