-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
158 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"] | ||
} |
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 @@ | ||
{ | ||
"extends": "stylelint-config-standard" | ||
} |
30 changes: 30 additions & 0 deletions
30
playground/stylelint-default/__tests__/__snapshots__/test.spec.ts.snap
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,30 @@ | ||
// Vitest Snapshot v1 | ||
|
||
exports[`stylelint > serve > get initial error and subsequent error 1`] = `"[{\\"checkerId\\":\\"Stylelint\\",\\"frame\\":\\" > 1 | #root {/n | ^/n > 2 | }/n | ^^/n 3 |/n 4 | body {/n 5 | color: rgb(0, 0, 0);\\",\\"id\\":\\"<PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css\\",\\"level\\":1,\\"loc\\":{\\"column\\":7,\\"file\\":\\"<PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css\\",\\"line\\":1},\\"message\\":\\"Unexpected empty block (block-no-empty) (block-no-empty)\\",\\"stack\\":\\"\\"},{\\"checkerId\\":\\"Stylelint\\",\\"frame\\":\\" 3 |/n 4 | body {/n > 5 | color: rgb(0, 0, 0);/n | ^^^^^^^^^^^^/n 6 | }/n 7 |\\",\\"id\\":\\"<PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css\\",\\"level\\":1,\\"loc\\":{\\"column\\":10,\\"file\\":\\"<PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css\\",\\"line\\":5},\\"message\\":\\"Expected modern color-function notation (color-function-notation) (color-function-notation)\\",\\"stack\\":\\"\\"}]"`; | ||
|
||
exports[`stylelint > serve > get initial error and subsequent error 2`] = ` | ||
" ERROR(Stylelint) Unexpected empty block (block-no-empty) (block-no-empty) | ||
FILE <PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css:1:7 | ||
> 1 | #root { | ||
| ^ | ||
> 2 | } | ||
| ^^ | ||
3 | | ||
4 | body { | ||
5 | color: rgb(0, 0, 0); | ||
ERROR(Stylelint) Expected modern color-function notation (color-function-notation) (color-function-notation) | ||
FILE <PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css:5:10 | ||
3 | | ||
4 | body { | ||
> 5 | color: rgb(0, 0, 0); | ||
| ^^^^^^^^^^^^ | ||
6 | } | ||
7 | | ||
[Stylelint] Found 2 errors and 0 warning" | ||
`; | ||
exports[`stylelint > serve > get initial error and subsequent error 3`] = `"[{\\"checkerId\\":\\"Stylelint\\",\\"frame\\":\\" > 1 | #root {/n | ^/n > 2 | }/n | ^^/n 3 |/n 4 | body {/n 5 | color: rgb(0, 0, 0);\\",\\"id\\":\\"<PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css\\",\\"level\\":1,\\"loc\\":{\\"column\\":7,\\"file\\":\\"<PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css\\",\\"line\\":1},\\"message\\":\\"Unexpected empty block (block-no-empty) (block-no-empty)\\",\\"stack\\":\\"\\"},{\\"checkerId\\":\\"Stylelint\\",\\"frame\\":\\" 3 |/n 4 | body {/n > 5 | color: rgb(0, 0, 0);/n | ^^^^^^^^^^^^/n 6 | }/n 7 |\\",\\"id\\":\\"<PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css\\",\\"level\\":1,\\"loc\\":{\\"column\\":10,\\"file\\":\\"<PROJECT_ROOT>/playground-temp/stylelint-default/src/style.css\\",\\"line\\":5},\\"message\\":\\"Expected modern color-function notation (color-function-notation) (color-function-notation)\\",\\"stack\\":\\"\\"}]"`; | ||
exports[`stylelint > serve > get initial error and subsequent error 4`] = `""`; |
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,39 @@ | ||
import stringify from 'fast-json-stable-stringify' | ||
import { describe, expect, it } from 'vitest' | ||
import { | ||
diagnostics, | ||
editFile, | ||
expectStderrContains, | ||
isBuild, | ||
isServe, | ||
log, | ||
resetReceivedLog, | ||
sleepForEdit, | ||
sleepForServerReady, | ||
stripedLog, | ||
} from '../../testUtils' | ||
|
||
describe('stylelint', () => { | ||
describe.runIf(isServe)('serve', () => { | ||
it('get initial error and subsequent error', async () => { | ||
await sleepForServerReady() | ||
expect(stringify(diagnostics)).toMatchSnapshot() | ||
expect(stripedLog).toMatchSnapshot() | ||
|
||
console.log('-- edit error file --') | ||
resetReceivedLog() | ||
editFile('src/style.css', (code) => code.replace(`color: rgb(0, 0, 0);`, `color: #fff;`)) | ||
await sleepForEdit() | ||
expect(stringify(diagnostics)).toMatchSnapshot() | ||
expect(stripedLog).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe.runIf(isBuild)('build', () => { | ||
const expectedMsg = ['Unexpected empty block', 'Expected modern color-function notation'] | ||
|
||
it('should fail', async () => { | ||
expectStderrContains(log, expectedMsg) | ||
}) | ||
}) | ||
}) |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="src/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
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,26 @@ | ||
{ | ||
"private": true, | ||
"name": "@playground/stylelint-default", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"serve": "vite preview", | ||
"lint": "stylelint \"./**/*.css\"" | ||
}, | ||
"dependencies": { | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"meow": "^9.0.0", | ||
"stylelint": "^14.0.0", | ||
"stylelint-config-standard": "^28.0.0", | ||
"typescript": "~4.5.5", | ||
"vite": "^3.0.4", | ||
"vite-plugin-checker": "workspace:*" | ||
} | ||
} |
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,6 @@ | ||
import './style.css' | ||
|
||
const rootDom = document.querySelector('#root')! | ||
rootDom.innerHTML = 'Hello world.' | ||
|
||
export {} |
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,6 @@ | ||
#root { | ||
} | ||
|
||
body { | ||
color: rgb(0, 0, 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,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"lib": ["DOM", "DOM.Iterable", "ESNext"], | ||
"types": ["vite/client"], | ||
"allowJs": false, | ||
"skipLibCheck": false, | ||
"esModuleInterop": false, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": true | ||
}, | ||
"include": ["./src"] | ||
} |
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,12 @@ | ||
import { defineConfig } from 'vite' | ||
import checker from 'vite-plugin-checker' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
checker({ | ||
stylelint: { | ||
lintCommand: 'stylelint ./**/*.css', | ||
}, | ||
}), | ||
], | ||
}) |