Skip to content

Commit a2f35d6

Browse files
committed
Merge branch 'master' into beta
2 parents c20a84f + 7f6eca6 commit a2f35d6

File tree

15 files changed

+204
-62
lines changed

15 files changed

+204
-62
lines changed

README.md

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
<div align="center">
22
<br>
3-
<img width="200" src="https://user-images.githubusercontent.com/288160/95671736-22da8400-0b4f-11eb-953c-339440756a3d.png" alt="Hover Web">
3+
<img width="200" src="https://user-images.githubusercontent.com/288160/95674568-ed8d6080-0b65-11eb-88be-d119c88ee285.png" alt="Hover Web">
44
<br>
55
<h1>hover-javascript</h1>
6-
<p>CLI toolbox for common scripts for <strong>JavaScript</strong> and <strong>TypeScript</strong> projects</p></div>
6+
<p>🧰 Toolbox of scripts and configurations for <strong>JavaScript</strong> and <strong>TypeScript</strong> projects</p></div>
77

8-
---
8+
<div align="center">
9+
10+
[![Build Status][build-badge]][build-link]
11+
[![Code Coverage][coverage-badge]][coverage-link]
12+
[![Version][package-badge]][package-link]
13+
[![Maintenance][maintenance-badge]][maintenance-link]
14+
[![Node Version][node-badge]][node-link]
15+
[![MIT License][license-badge]][license-link]
16+
[![Code Style][prettier-badge]][prettier-link]
17+
[![Conventional Commits][conventional-commits-badge]][conventional-commits-link]
18+
19+
</div>
920

10-
[![Build Status][build-badge]][build]
11-
[![Code Coverage][coverage-badge]][coverage]
12-
[![Dependabot Status][dependabot-badge]][dependabot]
13-
[![version][version-badge]][package] [![MIT License][license-badge]][license]
21+
<br>
22+
23+
## ✨ Features
1424

15-
This is a CLI that abstracts away all configuration for ~~my~~ **our** open
16-
source projects for linting, testing, building, and more.
25+
- 📦 One package to encapsulate most tooling dependencies
26+
- ⚙️ Common (extensible) configurations to eliminate boilerplate
27+
- 📏 Conventions that help enforce consistency
28+
- 🥽 Best practices to help avoid 🦶🏻🔫
1729

1830
## Contents
1931

@@ -23,14 +35,19 @@ source projects for linting, testing, building, and more.
2335
- [Installation](#installation)
2436
- [Usage](#usage)
2537
- [Overriding Config](#overriding-config)
26-
- [LICENSE](#license)
38+
- [ESLint](#eslint)
39+
- [Prettier](#prettier)
40+
- [Jest](#jest)
41+
- [License](#license)
42+
- [Maintenance](#maintenance)
2743

2844
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
2945

3046
## Installation
3147

32-
This module is distributed via [npm][npm] which is bundled with [node][node] and
33-
should be installed as one of your project's `devDependencies`:
48+
This module is distributed via [npm][npm-link] which is bundled with
49+
[node][node-link] and should be installed as one of your project's
50+
`devDependencies`:
3451

3552
```
3653
yarn add -D @hover/javascript
@@ -58,6 +75,10 @@ and override only the parts of the config you need to.
5875
This can be a very helpful way to make editor integration work for tools like
5976
ESLint which require project-based ESLint configuration to be present to work.
6077

78+
> Note: `hover-scripts` intentionally does not merge things for you when you
79+
> start configuring things to make it less magical and more straightforward.
80+
> Extending can take place on your terms.
81+
6182
#### ESLint
6283

6384
So, if we were to do this for ESLint, you could create an `.eslintrc.js` with
@@ -97,32 +118,39 @@ module.exports = {
97118
}
98119
```
99120

100-
> Note: `hover-scripts` intentionally does not merge things for you when you
101-
> start configuring things to make it less magical and more straightforward.
102-
> Extending can take place on your terms. ~~I~~ _Kent_ think[s] this is actually
103-
> a great way to do this.
104-
>
105-
> For the record, so do I (Jamie)
121+
## License
122+
123+
## Maintenance
106124

107-
## LICENSE
125+
This project is actively maintained by engineers at
126+
[@hoverinc][hover-github-link] 😀.
108127

109128
MIT
110129

130+
[hover-github-link]: https://github.com/hoverinc
131+
[node-link]: https://nodejs.org
132+
[npm-link]: https://www.npmjs.com/
111133
[react-scripts-link]:
112134
https://github.com/facebook/create-react-app/tree/master/packages/react-scripts
113-
[npm]: https://www.npmjs.com/
114-
[node]: https://nodejs.org
115135
[build-badge]:
116136
https://g.codefresh.io/api/badges/pipeline/hoverinc/npm%2Fjavascript?type=cf-1
117-
[build]:
137+
[build-link]:
118138
https://g.codefresh.io/public/accounts/hoverinc/pipelines/5d4cb5d4e41f3722d4dfdb94
139+
[conventional-commits-badge]:
140+
https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg
141+
[conventional-commits-link]: https://conventionalcommits.org
142+
[coverage-link]: https://codecov.io/github/hoverinc/hover-javascript
119143
[coverage-badge]:
120144
https://img.shields.io/codecov/c/github/hoverinc/hover-javascript.svg
121-
[coverage]: https://codecov.io/github/hoverinc/hover-javascript
122-
[dependabot-badge]:
123-
https://api.dependabot.com/badges/status?host=github&repo=hoverinc/hover-javascript
124-
[dependabot]: https://dependabot.com
125-
[version-badge]: https://img.shields.io/npm/v/@hover/javascript.svg
126-
[package]: https://www.npmjs.com/package/@hover/javascript
145+
[maintenance-badge]:
146+
https://img.shields.io/badge/maintenance-active-247ddc?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAcCAYAAACUJBTQAAAB1ElEQVRIibWWPUtdQRCGH0VNF/wCCVjYCxr/gZWdhYVgLQYbm/wACTYxxA8SSBDtbKwUbfQWkiJFAgkkmHBBY6U2CXaCGlDDG1buxePOnt17bsgD28zOzjtnZvbuRVKR1SFpVdKepEe1njOGnOWCz0q60B1lSa05/oVE2iTNSfqdCZ7lSyWB0NmkSJekeUmXJqzlayWZUJxckUUTJs23mFAjlhNjSdMHfAQ6g54hZUnDdXyN44ek7iKNH4w0PMaeX7pQ8Ox6HQkWww3Dw1hPWoAJ4BxoB4aNR5oB4APQ5vekUdITSceZDLcreyORrGPcfpEL0CBpVNJRwLmUSWLS7NbGpju8FXEteT2qR+jQ9aS3QK2XgUljjXPpRC6iLpYV4KmxRghNVy28Aqb+t4jjLbBhrAH+RcRxZSwBUiINxlIHKZE/xlIHTTlHBDwHjoDPwHtgF/gEnBnvFJVfzSrXkpYyfxKGvIu14F3ONXP1LOWmzEPjpuWl92j55XyQyDnEjRN5AbwD9gMOPkV7tAPMOJE3ZuuOFmOpjS3gGfCdQDl8fgGnGVtzwt8F7wdGqgKOvOmq4iarB3gMjAFlb78qug5MAwehIO4tKViJe4wDP4FSrgfwF/ntR8JxRSf3AAAAAElFTkSuQmCC
147+
[maintenance-link]: https://github.com/hoverinc/hover-javascript#maintenance
127148
[license-badge]: https://img.shields.io/npm/l/@hover/javascript.svg
128-
[license]: https://github.com/hoverinc/hover-javascript/blob/master/LICENSE
149+
[license-link]: https://github.com/hoverinc/hover-javascript/blob/master/LICENSE
150+
[node-link]: https://nodejs.org/en/download/
151+
[node-badge]: https://img.shields.io/badge/node-v12.18.4-green
152+
[prettier-badge]:
153+
https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier
154+
[prettier-link]: https://prettierjs.org/en/download/
155+
[package-badge]: https://img.shields.io/npm/v/@hover/javascript.svg
156+
[package-link]: https://www.npmjs.com/package/@hover/javascript

commitlint.config.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
const {readdirSync, statSync} = require('fs')
2-
const {join, sep} = require('path')
3-
4-
const ls = path =>
5-
readdirSync(path)
6-
.filter(f => statSync(join(path, f)).isFile())
7-
.map(
8-
f =>
9-
`${path.split(sep).reverse()[0]}/${f.replace(
10-
/(\.config)?.(json|js)/,
11-
'',
12-
)}`,
13-
)
1+
const {ls, scopes} = require('./src/api/commit')
142

153
module.exports = {
164
extends: ['./src/config/commitlint.config'],
@@ -19,11 +7,13 @@ module.exports = {
197
1,
208
'always',
219
[
22-
...ls('./src/config'),
23-
...ls('./src/scripts'),
24-
...ls('./src/api'),
25-
'deps',
26-
'build',
10+
...scopes.build(),
11+
'config',
12+
'scripts',
13+
'api',
14+
...ls.configs('./src/config'),
15+
...ls.configs('./src/scripts'),
16+
...ls.configs('./src/api'),
2717
],
2818
],
2919
},

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"license": "MIT",
5151
"dependencies": {
5252
"@commitlint/cli": "^11.0.0",
53-
"@commitlint/config-conventional": "^9.1.2",
53+
"@commitlint/config-conventional": "^11.0.0",
5454
"@commitlint/prompt": "^11.0.0",
5555
"@types/jest": "^26.0.14",
5656
"@typescript-eslint/eslint-plugin": "^4.4.0",
@@ -90,7 +90,7 @@
9090
"semver": "^7.1.3",
9191
"typescript": "^4.0.3",
9292
"which": "^2.0.2",
93-
"yargs-parser": "^18.1.3"
93+
"yargs-parser": "^20.2.1"
9494
},
9595
"eslintConfig": {
9696
"extends": [

src/api/__tests__/__fixtures__/ls/configs/.foorc.json

Whitespace-only changes.

src/api/__tests__/__fixtures__/ls/configs/foo.config.js

Whitespace-only changes.

src/api/__tests__/__fixtures__/ls/configs/foo.js

Whitespace-only changes.

src/api/__tests__/__fixtures__/ls/configs/foo.setup.ts

Whitespace-only changes.

src/api/__tests__/__fixtures__/ls/dirs/.baz/.gitkeep

Whitespace-only changes.

src/api/__tests__/__fixtures__/ls/dirs/bar/.gitkeep

Whitespace-only changes.

src/api/__tests__/__fixtures__/ls/dirs/foo/.gitkeep

Whitespace-only changes.

src/api/__tests__/commit.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const {ls} = require('../commit')
2+
3+
const fixtures = './src/api/__tests__/__fixtures__'
4+
5+
describe('ls', () => {
6+
test('configs', () => {
7+
const result = ls.configs(`${fixtures}/ls/configs`)
8+
9+
const expected = [
10+
'configs/.foorc',
11+
'configs/foo',
12+
'configs/foo.setup',
13+
'configs/foo',
14+
]
15+
16+
expect(result.sort()).toEqual(expected.sort())
17+
})
18+
19+
describe('dirs', () => {
20+
test('without prefix', () => {
21+
const result = ls.dirs(`${fixtures}/ls/dirs`)
22+
23+
const expected = ['.baz', 'bar', 'foo']
24+
25+
expect(result.sort()).toEqual(expected.sort())
26+
})
27+
28+
test('with prefix', () => {
29+
const result = ls.dirs(`${fixtures}/ls/dirs`, 'prefix')
30+
31+
const expected = ['prefix/.baz', 'prefix/bar', 'prefix/foo']
32+
33+
expect(result.sort()).toEqual(expected.sort())
34+
})
35+
})
36+
})

src/api/commit.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
const {readdirSync, statSync} = require('fs')
2+
const {join, sep} = require('path')
3+
4+
//
5+
// Common scopes
6+
7+
/**
8+
* Build scopes
9+
* - commit
10+
* - deps
11+
* - deps-dev
12+
* - format
13+
* - lint
14+
*/
15+
const build = () => ['commit', 'deps', 'deps-dev', 'format', 'lint']
16+
17+
const scopes = {build}
18+
19+
//
20+
// Scope helpers
21+
22+
/**
23+
* Enumerate config files
24+
*
25+
* Example
26+
*
27+
* - `dir/foo.js`
28+
* - `dir/bar.config.js`
29+
* - `dir/baz.json`
30+
* - `dir/qux.ts`
31+
*
32+
* `ls.config('./dir') → ['dir/foo', 'dir/bar', 'dir/baz', 'dir/qux']`
33+
*
34+
* @param {string} path - directory to enumerate
35+
*/
36+
const configs = path =>
37+
readdirSync(path)
38+
.filter(f => statSync(join(path, f)).isFile())
39+
.map(
40+
f =>
41+
`${path.split(sep).reverse()[0]}/${f.replace(
42+
/(\.config)?.(json|js|ts)/,
43+
'',
44+
)}`,
45+
)
46+
47+
/**
48+
* Enumerate one level of directories
49+
*
50+
* @param {string} path - directory to enumerate
51+
* @param {string} [prefix] - prefix for each scope entry (e.g: `prefix/entry`)
52+
*/
53+
const dirs = (path, prefix) =>
54+
readdirSync(path)
55+
.filter(f => statSync(join(path, f)).isDirectory())
56+
.map(item => (prefix ? `${prefix}/${item}` : item))
57+
.map(item => item.toLowerCase())
58+
59+
const ls = {configs, dirs}
60+
61+
module.exports = {ls, scopes}

src/config/commitlint.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const {scopes} = require('../api/commit')
2+
13
module.exports = {
24
extends: ['@commitlint/config-conventional'],
35
rules: {
@@ -19,6 +21,6 @@ module.exports = {
1921
],
2022
],
2123
'scope-case': [1, 'always', 'kebab-case'],
22-
'scope-enum': [0, 'always', ['deps', 'build']],
24+
'scope-enum': [0, 'always', scopes.build()],
2325
},
2426
}

src/config/lintstagedrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const hoverScripts = resolveHoverScripts()
44
const doctoc = resolveBin('doctoc')
55

66
module.exports = {
7-
'README.md': [`${doctoc} --maxlevel 3 --notitle`],
7+
'README.md': [`${doctoc} --maxlevel 4 --notitle`],
88
'*.+(js|jsx|json|yml|yaml|css|less|scss|ts|tsx|md|graphql|mdx|vue)': [
99
`${hoverScripts} format`,
1010
],

0 commit comments

Comments
 (0)