Skip to content

Commit

Permalink
build: spellchecker (#689)
Browse files Browse the repository at this point in the history
* build(cspell): add spellchecker
* build(cspell): add cspell github-action
* docs: fix spelling mistakes
  • Loading branch information
chimurai authored Dec 24, 2021
1 parent 6ca729e commit 92f75c4
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 14 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,50 @@ jobs:
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}

spellcheck:
name: Spellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: streetsidesoftware/cspell-action@main
with:
# Github token used to fetch the list of changed files in the commit.
# Default: ${{ github.token }}
github_token: ${{ github.token }}

# Define glob patterns to filter the files to be checked. Use a new line between patterns to define multiple patterns.
# The default is to check ALL files that were changed in in the pull_request or push.
# Note: `ignorePaths` defined in cspell.json still apply.
# Example:
# files: |
# **/*.{ts,js}
# !dist/**/*.{ts,js}
# # Hidden directories need an explicit .* to be included
# .*/**/*.yml
#
# To not check hidden files, use:
# files: "**"
#
# Default: ALL files
files: '**'

# The point in the directory tree to start spell checking.
# Default: .
root: '.'

# Notification level to use with inline reporting of spelling errors.
# Allowed values are: warning, error, none
# Default: warning
inline: error

# Determines if the action should be failed if any spelling issues are found.
# Allowed values are: true, false
# Default: true
strict: true

# Limit the files checked to the ones in the pull request or push.
incremental_files_only: false

# Path to `cspell.json`
config: 'cspell.json'
19 changes: 19 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
aremishevsky
Bezalel
bforbis
Chim
cloudmu
dylang
Elad
graingert
julbra
leonardobazico
Liran
midgleyc
mpth
oshri
oufeng
rsethc
sunnylqm
Tazelaar
trbngr
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Subscribe to [http-proxy events](https://github.com/nodejitsu/node-http-proxy#li
```javascript
function onOpen(proxySocket) {
// listen for messages coming FROM the target here
proxySocket.on('data', hybiParseAndLogMessage);
proxySocket.on('data', hybridParseAndLogMessage);
}
```
Expand Down Expand Up @@ -585,6 +585,9 @@ $ yarn test

# code coverage
$ yarn cover

# check spelling mistakes
$ yarn spellcheck
```
## Changelog
Expand Down
40 changes: 40 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"language": "en",
"spellCheckDelayMs": 500,
"dictionaries": ["node", "npm", "typescript", "contributors"],
"ignorePaths": ["node_modules/**", "coverage/**", "dist/**", "package.json", "yarn.lock"],
"dictionaryDefinitions": [
{
"name": "contributors",
"path": "CONTRIBUTORS.txt"
}
],
"ignoreRegExpList": ["[a-z]+path"],
"words": [
"camelcase",
"codesandbox",
"deepcode",
"depthfrom",
"fastify",
"globbing",
"gzipped",
"insertanchor",
"lcov",
"Lenna",
"lipsum",
"lorum",
"middlewares",
"millis",
"mockttp",
"Nodejitsu",
"ntlm",
"proxied",
"proxying",
"rawbody",
"restream",
"streamify",
"vhosted",
"websockets",
"xfwd"
]
}
1 change: 1 addition & 0 deletions examples/response-interceptor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const express = require('express');
const { createProxyMiddleware, responseInterceptor } = require('../../dist'); // require('http-proxy-middleware');

// test with double-byte characters
// cSpell:ignore Kroket, ส้มตำไทย, चिकन
const favoriteFoods = [
{
country: 'NL',
Expand Down
2 changes: 1 addition & 1 deletion examples/websocket/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h2>WebSocket demo</h2>
log('DISCONNECTED');
});
socket.addEventListener('error', () => {
log('SOCKET ERROR OCCURED');
log('SOCKET ERROR OCCURRED');
});
socket.addEventListener('message', (msg) => {
log('RECEIVED:' + msg.data);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"precoverage": "yarn build",
"coverage": "jest --coverage --coverageReporters=lcov",
"prepare": "husky install",
"prepack": "yarn build && rm dist/tsconfig.tsbuildinfo"
"prepack": "yarn build && rm dist/tsconfig.tsbuildinfo",
"spellcheck": "npx --yes cspell --show-context --show-suggestions '**/*.*'"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion recipes/async-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const myProxy = createProxyMiddleware({
selfHandleResponse: true,
onProxyReq: (proxyReq, req, res) => {
// before
// get something async from entry middlware before the proxy kicks in
// get something async from entry middleware before the proxy kicks in
console.log('proxyReq:', req.locals.da);

proxyReq.setHeader('mpth-1', req.locals.da);
Expand Down
2 changes: 1 addition & 1 deletion recipes/logLevel.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Possible values:

## Level: debug

Log everyting.
Log everything.

```javascript
const { createProxyMiddleware } = require('http-proxy-middleware');
Expand Down
2 changes: 1 addition & 1 deletion recipes/logProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const logProvider = function (provider) {
const logger = new winston.Logger({
transports: [
new winston.transports.Console(),
new winston.transports.File({ filename: 'somefile.log' }),
new winston.transports.File({ filename: 'some-file.log' }),
],
});

Expand Down
4 changes: 2 additions & 2 deletions recipes/modify-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const proxy_options = {
let body = new Object();

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

// URI encode JSON object
body = Object.keys(body)
Expand Down
2 changes: 1 addition & 1 deletion recipes/response-interceptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Some working examples on <https://03rjl.sse.codesandbox.io>/[relative wikimedia
_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._

```javascript
const Jimp = require('jimp'); // use jimp libray for image manipulation
const Jimp = require('jimp'); // use jimp library for image manipulation

const proxy = createProxyMiddleware({
target: 'https://upload.wikimedia.org',
Expand Down
1 change: 1 addition & 0 deletions test/e2e/websocket.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ describe('E2E WebSocket proxy', () => {
beforeEach(() => {
// override
proxyServer = createApp(
// cSpell:ignore notworkinghost
createProxyMiddleware('ws://notworkinghost:6789', {
router: { '/socket': `ws://localhost:${WS_SERVER_PORT}` },
pathRewrite: { '^/socket': '' },
Expand Down
6 changes: 2 additions & 4 deletions test/unit/response-interceptor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ describe('responseInterceptor', () => {
response
);

httpIncomingMessage.emit('error', new Error('some error meessage'));
httpIncomingMessage.emit('error', new Error('some error message'));

expect(response.setHeader).not.toHaveBeenCalled();
expect(response.write).not.toHaveBeenCalled();
expect(response.end).toHaveBeenCalledWith(
'Error fetching proxied request: some error meessage'
);
expect(response.end).toHaveBeenCalledWith('Error fetching proxied request: some error message');
});
});
2 changes: 1 addition & 1 deletion test/unit/router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('router unit test', () => {
});

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

0 comments on commit 92f75c4

Please sign in to comment.