Skip to content

Commit 92f75c4

Browse files
authored
build: spellchecker (#689)
* build(cspell): add spellchecker * build(cspell): add cspell github-action * docs: fix spelling mistakes
1 parent 6ca729e commit 92f75c4

15 files changed

+124
-14
lines changed

.github/workflows/ci.yml

+47
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,50 @@ jobs:
9595
uses: coverallsapp/github-action@master
9696
with:
9797
github-token: ${{ secrets.github_token }}
98+
99+
spellcheck:
100+
name: Spellcheck
101+
runs-on: ubuntu-latest
102+
steps:
103+
- uses: actions/checkout@v2
104+
- uses: streetsidesoftware/cspell-action@main
105+
with:
106+
# Github token used to fetch the list of changed files in the commit.
107+
# Default: ${{ github.token }}
108+
github_token: ${{ github.token }}
109+
110+
# Define glob patterns to filter the files to be checked. Use a new line between patterns to define multiple patterns.
111+
# The default is to check ALL files that were changed in in the pull_request or push.
112+
# Note: `ignorePaths` defined in cspell.json still apply.
113+
# Example:
114+
# files: |
115+
# **/*.{ts,js}
116+
# !dist/**/*.{ts,js}
117+
# # Hidden directories need an explicit .* to be included
118+
# .*/**/*.yml
119+
#
120+
# To not check hidden files, use:
121+
# files: "**"
122+
#
123+
# Default: ALL files
124+
files: '**'
125+
126+
# The point in the directory tree to start spell checking.
127+
# Default: .
128+
root: '.'
129+
130+
# Notification level to use with inline reporting of spelling errors.
131+
# Allowed values are: warning, error, none
132+
# Default: warning
133+
inline: error
134+
135+
# Determines if the action should be failed if any spelling issues are found.
136+
# Allowed values are: true, false
137+
# Default: true
138+
strict: true
139+
140+
# Limit the files checked to the ones in the pull request or push.
141+
incremental_files_only: false
142+
143+
# Path to `cspell.json`
144+
config: 'cspell.json'

CONTRIBUTORS.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
aremishevsky
2+
Bezalel
3+
bforbis
4+
Chim
5+
cloudmu
6+
dylang
7+
Elad
8+
graingert
9+
julbra
10+
leonardobazico
11+
Liran
12+
midgleyc
13+
mpth
14+
oshri
15+
oufeng
16+
rsethc
17+
sunnylqm
18+
Tazelaar
19+
trbngr

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Subscribe to [http-proxy events](https://github.com/nodejitsu/node-http-proxy#li
340340
```javascript
341341
function onOpen(proxySocket) {
342342
// listen for messages coming FROM the target here
343-
proxySocket.on('data', hybiParseAndLogMessage);
343+
proxySocket.on('data', hybridParseAndLogMessage);
344344
}
345345
```
346346

@@ -585,6 +585,9 @@ $ yarn test
585585

586586
# code coverage
587587
$ yarn cover
588+
589+
# check spelling mistakes
590+
$ yarn spellcheck
588591
```
589592

590593
## Changelog

cspell.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"language": "en",
3+
"spellCheckDelayMs": 500,
4+
"dictionaries": ["node", "npm", "typescript", "contributors"],
5+
"ignorePaths": ["node_modules/**", "coverage/**", "dist/**", "package.json", "yarn.lock"],
6+
"dictionaryDefinitions": [
7+
{
8+
"name": "contributors",
9+
"path": "CONTRIBUTORS.txt"
10+
}
11+
],
12+
"ignoreRegExpList": ["[a-z]+path"],
13+
"words": [
14+
"camelcase",
15+
"codesandbox",
16+
"deepcode",
17+
"depthfrom",
18+
"fastify",
19+
"globbing",
20+
"gzipped",
21+
"insertanchor",
22+
"lcov",
23+
"Lenna",
24+
"lipsum",
25+
"lorum",
26+
"middlewares",
27+
"millis",
28+
"mockttp",
29+
"Nodejitsu",
30+
"ntlm",
31+
"proxied",
32+
"proxying",
33+
"rawbody",
34+
"restream",
35+
"streamify",
36+
"vhosted",
37+
"websockets",
38+
"xfwd"
39+
]
40+
}

examples/response-interceptor/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const express = require('express');
88
const { createProxyMiddleware, responseInterceptor } = require('../../dist'); // require('http-proxy-middleware');
99

1010
// test with double-byte characters
11+
// cSpell:ignore Kroket, ส้มตำไทย, चिकन
1112
const favoriteFoods = [
1213
{
1314
country: 'NL',

examples/websocket/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ <h2>WebSocket demo</h2>
9393
log('DISCONNECTED');
9494
});
9595
socket.addEventListener('error', () => {
96-
log('SOCKET ERROR OCCURED');
96+
log('SOCKET ERROR OCCURRED');
9797
});
9898
socket.addEventListener('message', (msg) => {
9999
log('RECEIVED:' + msg.data);

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"precoverage": "yarn build",
2323
"coverage": "jest --coverage --coverageReporters=lcov",
2424
"prepare": "husky install",
25-
"prepack": "yarn build && rm dist/tsconfig.tsbuildinfo"
25+
"prepack": "yarn build && rm dist/tsconfig.tsbuildinfo",
26+
"spellcheck": "npx --yes cspell --show-context --show-suggestions '**/*.*'"
2627
},
2728
"repository": {
2829
"type": "git",

recipes/async-response.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const myProxy = createProxyMiddleware({
5050
selfHandleResponse: true,
5151
onProxyReq: (proxyReq, req, res) => {
5252
// before
53-
// get something async from entry middlware before the proxy kicks in
53+
// get something async from entry middleware before the proxy kicks in
5454
console.log('proxyReq:', req.locals.da);
5555

5656
proxyReq.setHeader('mpth-1', req.locals.da);

recipes/logLevel.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Possible values:
1212

1313
## Level: debug
1414

15-
Log everyting.
15+
Log everything.
1616

1717
```javascript
1818
const { createProxyMiddleware } = require('http-proxy-middleware');

recipes/logProvider.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const logProvider = function (provider) {
6060
const logger = new winston.Logger({
6161
transports: [
6262
new winston.transports.Console(),
63-
new winston.transports.File({ filename: 'somefile.log' }),
63+
new winston.transports.File({ filename: 'some-file.log' }),
6464
],
6565
});
6666

recipes/modify-post.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ const proxy_options = {
4444
let body = new Object();
4545

4646
body.filename = 'reports/statistics/summary_2016.pdf';
47-
body.routeid = 's003b012d002';
48-
body.authid = 'bac02c1d-258a-4177-9da6-862580154960';
47+
body.routeId = 's003b012d002';
48+
body.authId = 'bac02c1d-258a-4177-9da6-862580154960';
4949

5050
// URI encode JSON object
5151
body = Object.keys(body)

recipes/response-interceptor.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Some working examples on <https://03rjl.sse.codesandbox.io>/[relative wikimedia
9999
_You can just use any relative image path from <https://upload.wikimedia.org> and use the relative image path on <https://03rjl.sse.codesandbox.io> to see the manipulated image._
100100

101101
```javascript
102-
const Jimp = require('jimp'); // use jimp libray for image manipulation
102+
const Jimp = require('jimp'); // use jimp library for image manipulation
103103

104104
const proxy = createProxyMiddleware({
105105
target: 'https://upload.wikimedia.org',

test/e2e/websocket.spec.ts

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ describe('E2E WebSocket proxy', () => {
125125
beforeEach(() => {
126126
// override
127127
proxyServer = createApp(
128+
// cSpell:ignore notworkinghost
128129
createProxyMiddleware('ws://notworkinghost:6789', {
129130
router: { '/socket': `ws://localhost:${WS_SERVER_PORT}` },
130131
pathRewrite: { '^/socket': '' },

test/unit/response-interceptor.spec.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,10 @@ describe('responseInterceptor', () => {
5252
response
5353
);
5454

55-
httpIncomingMessage.emit('error', new Error('some error meessage'));
55+
httpIncomingMessage.emit('error', new Error('some error message'));
5656

5757
expect(response.setHeader).not.toHaveBeenCalled();
5858
expect(response.write).not.toHaveBeenCalled();
59-
expect(response.end).toHaveBeenCalledWith(
60-
'Error fetching proxied request: some error meessage'
61-
);
59+
expect(response.end).toHaveBeenCalledWith('Error fetching proxied request: some error message');
6260
});
6361
});

test/unit/router.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ describe('router unit test', () => {
144144
});
145145

146146
it('should target http://localhost:6000 path in not present in router config', () => {
147-
fakeReq.url = '/unknow-path';
147+
fakeReq.url = '/unknown-path';
148148
result = getTarget(fakeReq, proxyOptionWithRouter);
149149
return expect(result).resolves.toBeUndefined();
150150
});

0 commit comments

Comments
 (0)