Skip to content

Commit 99fa00f

Browse files
committed
chore: initial commit
0 parents  commit 99fa00f

14 files changed

+4966
-0
lines changed

.gitignore

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
# Created by https://www.gitignore.io/api/node
3+
4+
### Node ###
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
24+
# nyc test coverage
25+
.nyc_output
26+
27+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
28+
.grunt
29+
30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
33+
# node-waf configuration
34+
.lock-wscript
35+
36+
# Compiled binary addons (http://nodejs.org/api/addons.html)
37+
build/Release
38+
39+
# Dependency directories
40+
node_modules/
41+
jspm_packages/
42+
43+
# Typescript v1 declaration files
44+
typings/
45+
46+
# Optional npm cache directory
47+
.npm
48+
49+
# Optional eslint cache
50+
.eslintcache
51+
52+
# Optional REPL history
53+
.node_repl_history
54+
55+
# Output of 'npm pack'
56+
*.tgz
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# dotenv environment variables file
62+
.env
63+
64+
65+
# End of https://www.gitignore.io/api/node

.travis.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
language: node_js
2+
3+
node_js:
4+
- "node"
5+
- "lts/*"
6+
7+
install:
8+
- yarn
9+
10+
cache:
11+
directories:
12+
- "node_modules"
13+
- ~/.npm
14+
15+
notifications:
16+
email: false
17+
18+
jobs:
19+
include:
20+
- stage: test
21+
script:
22+
- yarn test
23+
after_success:
24+
- bash <(curl -s https://codecov.io/bash)
25+
- stage: release
26+
script:
27+
- npm run release
28+
after_sucess: skip
29+
30+
stages:
31+
- test
32+
- name: release
33+
if: branch = master AND type = push AND fork = false
34+
35+
branches:
36+
except:
37+
- /^v\d+\.\d+\.\d+$/

README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[![Build Status](https://travis-ci.org/keplersj/jest-runner-stylelint.svg?branch=master)](https://travis-ci.org/keplersj/jest-runner-stylelint)
2+
[![npm version](https://badge.fury.io/js/jest-runner-stylelint.svg)](https://badge.fury.io/js/jest-runner-stylelint)
3+
[![codecov](https://codecov.io/gh/keplersj/jest-runner-stylelint/branch/master/graph/badge.svg)](https://codecov.io/gh/keplersj/jest-runner-stylelint)
4+
5+
<div align="center">
6+
<!-- replace with accurate logo e.g from https://worldvectorlogo.com/ -->
7+
<a href="https://stylelint.io/">
8+
<img width="150" height="150" vspace="" hspace="25" src="https://cdn.worldvectorlogo.com/logos/stylelint.svg">
9+
</a>
10+
<a href="https://facebook.github.io/jest/">
11+
<img width="150" height="150" vspace="" hspace="25" src="https://cdn.worldvectorlogo.com/logos/jest.svg">
12+
</a>
13+
<h1>jest-runner-prettier</h1>
14+
<p>Prettier runner for Jest</p>
15+
</div>
16+
17+
<div align="center">
18+
<!--<img src="https://user-images.githubusercontent.com/574806/30197438-9681385c-941c-11e7-80a8-2b11f15bd412.gif">-->
19+
<!-- TODO: Create GIF showing off runner -->
20+
</div>
21+
22+
## Usage
23+
24+
### Install
25+
26+
Install `jest`_(it needs Jest 21+)_ and `jest-runner-stylelint`
27+
28+
```bash
29+
yarn add --dev jest jest-runner-stylelint
30+
31+
# or with NPM
32+
33+
npm install --save-dev jest jest-runner-stylelint
34+
```
35+
36+
### Add it to your Jest config
37+
38+
In your `package.json`
39+
40+
```json
41+
{
42+
"jest": {
43+
"runner": "jest-runner-stylelint",
44+
"moduleFileExtensions": [
45+
"css"
46+
],
47+
"testMatch": [
48+
"**/*.css"
49+
]
50+
}
51+
}
52+
```
53+
54+
Or in `jest.config.js`
55+
56+
```js
57+
module.exports = {
58+
runner: "jest-runner-stylelint",
59+
moduleFileExtensions: [
60+
"css"
61+
],
62+
testMatch: [
63+
"**/*.css"
64+
]
65+
};
66+
```
67+
68+
### Run Jest
69+
70+
```bash
71+
yarn jest
72+
```

commitlint.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ["@commitlint/config-conventional"] };

package.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "jest-runner-stylelint",
3+
"version": "1.0.0",
4+
"description": "Stylelint runner for Jest",
5+
"main": "src/index.js",
6+
"repository": "https://github.com/keplersj/jest-runner-stylelint",
7+
"author": "Kepler Sticka-Jones <[email protected]>",
8+
"license": "MIT",
9+
"private": false,
10+
"scripts": {
11+
"test": "jest",
12+
"commitmsg": "commitlint -e $GIT_PARAMS",
13+
"precommit": "lint-staged",
14+
"release": "semantic-release"
15+
},
16+
"lint-staged": {
17+
"*": ["jest --bail --findRelatedTests"]
18+
},
19+
"release": {
20+
"verifyConditions": "@semantic-release/github"
21+
},
22+
"jest": {
23+
"collectCoverage": true
24+
},
25+
"dependencies": {
26+
"create-jest-runner": "^0.1.1",
27+
"stylelint": "^8.3.1"
28+
},
29+
"devDependencies": {
30+
"@commitlint/cli": "^5.1.1",
31+
"@commitlint/config-conventional": "^5.1.3",
32+
"husky": "^0.14.3",
33+
"jest": "^21.2.1",
34+
"lint-staged": "^5.0.0",
35+
"semantic-release": "11",
36+
"stylelint-config-standard": "^18.0.0"
37+
}
38+
}

renovate.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": ["config:base"],
3+
"automerge": true,
4+
"automergeType": "branch-push",
5+
"major": {
6+
"automerge": false
7+
}
8+
}

src/__fixtures__/bad.css

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
img {
2+
width: 0px;
3+
height: 0px;
4+
}

src/__fixtures__/good.css

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
img {
2+
width: 0;
3+
height: 0;
4+
}

src/__fixtures__/stylelint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: "stylelint-config-standard"
3+
};

src/__snapshots__/run.test.js.snap

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`jest-runner-stylelint failing fixture matches snapshot 1`] = `
4+
Object {
5+
"console": null,
6+
"failureMessage": "
7+
src/__fixtures__/bad.css
8+
2:11 ✖ Unexpected unit length-zero-no-unit
9+
3:12 ✖ Unexpected unit length-zero-no-unit
10+
4:1 ✖ Unexpected missing end-of-source newline no-missing-end-of-source-newline
11+
12+
",
13+
"numFailingTests": 1,
14+
"numPassingTests": 0,
15+
"numPendingTests": 0,
16+
"skipped": undefined,
17+
"snapshot": Object {
18+
"added": 0,
19+
"fileDeleted": false,
20+
"matched": 0,
21+
"unchecked": 0,
22+
"unmatched": 0,
23+
"updated": 0,
24+
},
25+
"sourceMaps": Object {},
26+
"testExecError": null,
27+
"testResults": Array [
28+
Object {
29+
"ancestorTitles": Array [],
30+
"failureMessages": Array [
31+
"
32+
src/__fixtures__/bad.css
33+
2:11 ✖ Unexpected unit length-zero-no-unit
34+
3:12 ✖ Unexpected unit length-zero-no-unit
35+
4:1 ✖ Unexpected missing end-of-source newline no-missing-end-of-source-newline
36+
37+
",
38+
],
39+
"fullName": undefined,
40+
"numPassingAsserts": 1,
41+
"status": "failed",
42+
"title": "",
43+
},
44+
],
45+
}
46+
`;
47+
48+
exports[`jest-runner-stylelint passing fixture matches snapshot 1`] = `
49+
Object {
50+
"console": null,
51+
"failureMessage": undefined,
52+
"numFailingTests": 0,
53+
"numPassingTests": 1,
54+
"numPendingTests": 0,
55+
"skipped": undefined,
56+
"snapshot": Object {
57+
"added": 0,
58+
"fileDeleted": false,
59+
"matched": 0,
60+
"unchecked": 0,
61+
"unmatched": 0,
62+
"updated": 0,
63+
},
64+
"sourceMaps": Object {},
65+
"testExecError": null,
66+
"testResults": Array [
67+
Object {
68+
"ancestorTitles": Array [],
69+
"failureMessages": Array [
70+
undefined,
71+
],
72+
"fullName": undefined,
73+
"numPassingAsserts": 0,
74+
"status": "passed",
75+
"title": "",
76+
},
77+
],
78+
}
79+
`;

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const { createJestRunner } = require("create-jest-runner");
2+
module.exports = createJestRunner(require.resolve("./run"));

src/run.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const { pass, fail } = require("create-jest-runner");
2+
const stylelint = require("stylelint");
3+
4+
module.exports = ({ testPath, config, globalConfig }) => {
5+
const start = new Date();
6+
7+
return stylelint
8+
.lint({
9+
files: testPath,
10+
formatter: "string"
11+
})
12+
.then(data => {
13+
if (data.errored) {
14+
return fail({
15+
start,
16+
end: new Date(),
17+
test: {
18+
path: testPath,
19+
errorMessage: data.output
20+
}
21+
});
22+
}
23+
24+
return pass({
25+
start,
26+
end: new Date(),
27+
test: { path: testPath }
28+
});
29+
})
30+
.catch(err => {
31+
throw err;
32+
});
33+
};

0 commit comments

Comments
 (0)