-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
72bc45a
commit a4ec561
Showing
37 changed files
with
3,149 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,165 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
env: { | ||
es2017: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:eslint-comments/recommended', | ||
'plugin:node/recommended', | ||
'plugin:promise/recommended', | ||
'plugin:you-dont-need-lodash-underscore/compatible', | ||
], | ||
ignorePatterns: [ | ||
'node_modules/', | ||
], | ||
plugins: [ | ||
'eslint-comments', | ||
'node', | ||
'prefer-arrow', | ||
'promise', | ||
'you-dont-need-lodash-underscore', | ||
], | ||
root: true, | ||
rules: { | ||
'array-bracket-newline': ['error', 'consistent'], | ||
'array-bracket-spacing': 'error', | ||
'array-element-newline': ['error', 'consistent'], | ||
'arrow-body-style': 'error', | ||
'arrow-parens': 'error', | ||
'arrow-spacing': 'error', | ||
'block-spacing': 'error', | ||
'brace-style': ['error', '1tbs', {allowSingleLine: true}], | ||
'camelcase': 'error', | ||
'comma-dangle': ['error', { | ||
arrays: 'always-multiline', | ||
objects: 'always-multiline', | ||
imports: 'always-multiline', | ||
exports: 'always-multiline', | ||
functions: 'never', | ||
}], | ||
'comma-spacing': 'error', | ||
'comma-style': 'error', | ||
'computed-property-spacing': 'error', | ||
'curly': ['error', 'multi-line', 'consistent'], | ||
'dot-location': ['error', 'property'], | ||
'dot-notation': 'error', | ||
'eol-last': 'error', | ||
'eqeqeq': ['error', 'always', {null: 'never'}], | ||
'func-call-spacing': 'error', | ||
'guard-for-in': 'error', | ||
'implicit-arrow-linebreak': 'error', | ||
'indent': ['error', 2, { | ||
CallExpression: { | ||
arguments: 2, | ||
}, | ||
FunctionDeclaration: { | ||
parameters: 2, | ||
}, | ||
FunctionExpression: { | ||
parameters: 2, | ||
}, | ||
MemberExpression: 2, | ||
SwitchCase: 1, | ||
flatTernaryExpressions: true, | ||
offsetTernaryExpressions: true, | ||
}], | ||
'key-spacing': 'error', | ||
'keyword-spacing': 'error', | ||
'linebreak-style': 'error', | ||
'max-len': ['error', {code: 100, tabWidth: 2, ignoreUrls: true}], | ||
'new-cap': 'error', | ||
'new-parens': 'error', | ||
'no-array-constructor': 'error', | ||
'no-caller': 'error', | ||
'no-constant-condition': ['error', {checkLoops: false}], | ||
'no-duplicate-imports': 'error', | ||
'no-eval': 'error', | ||
'no-extend-native': 'error', | ||
'no-implicit-globals': 'error', | ||
'no-implied-eval': 'error', | ||
'no-lonely-if': 'error', | ||
'no-multi-spaces': 'error', | ||
'no-multi-str': 'error', | ||
'no-multiple-empty-lines': ['error', {max: 2, maxBOF: 0, maxEOF: 0}], | ||
'no-new-object': 'error', | ||
'no-new-wrappers': 'error', | ||
'no-nonoctal-decimal-escape': 'error', | ||
'no-prototype-builtins': 'error', | ||
'no-script-url': 'error', | ||
'no-sequences': 'error', | ||
'no-tabs': 'error', | ||
'no-throw-literal': 'error', | ||
'no-trailing-spaces': 'error', | ||
'no-unsafe-optional-chaining': 'error', | ||
'no-unused-vars': ['error', {args: 'none'}], | ||
'no-use-before-define': 'error', | ||
'no-var': 'error', | ||
'no-whitespace-before-property': 'error', | ||
'nonblock-statement-body-position': 'error', | ||
'object-curly-newline': 'error', | ||
'object-curly-spacing': 'error', | ||
'object-shorthand': 'error', | ||
'one-var': ['error', {initialized: 'never'}], | ||
'one-var-declaration-per-line': ['error', 'initializations'], | ||
'operator-assignment': 'error', | ||
'operator-linebreak': 'error', | ||
'padded-blocks': ['error', 'never'], | ||
'prefer-arrow-callback': 'error', | ||
'prefer-arrow/prefer-arrow-functions': 'error', | ||
'prefer-const': 'error', | ||
'prefer-exponentiation-operator': 'error', | ||
'prefer-promise-reject-errors': 'error', | ||
'prefer-rest-params': 'error', | ||
'prefer-spread': 'error', | ||
'prefer-template': 'error', | ||
// This rule is largely unnecessary thanks to the `await` keyword (`.then()` should be rare). | ||
// Also, being forced to add a return statement for a valueless Promise is annoying. | ||
'promise/always-return': 'off', | ||
// This rule is largely unnecessary because most browsers now log unhandled Promise rejections. | ||
'promise/catch-or-return': 'off', | ||
// Too many false positives. The docs for this rule say to use nodify, but in the following | ||
// example nodeify and util.callbackify() don't work because the `next` callback should not | ||
// always be called: | ||
// app.use((req, res, next) => { asyncMiddleware(req, res, next).catch(next); }); | ||
// This rule does catch legitimate issues, but as code is modernized with `async` and `await`, | ||
// this rule will become less relevant. | ||
'promise/no-callback-in-promise': 'off', | ||
// Too many false positives. In particular, there is no good way to process in parallel values | ||
// that were obtained asynchronously unless nested .then() calls are used. Example: | ||
// asyncGetItems().then((items) => Promise.all( | ||
// items.map((item) => asyncProcessItem(item).then(asyncConveyResults)))); | ||
// The nested .then() in the above example can be avoided by changing the logic like this: | ||
// asyncGetItems() | ||
// .then((items) => Promise.all(items.map(asyncProcessItem))) | ||
// .then((results) => Promise.all(results.map(asyncConveyResults))); | ||
// but there are problems with the logic change: | ||
// * No result will be conveyed if any of the processing calls fail. | ||
// * No result will be conveyed until all items are done being processed. | ||
// The proper way to address nested .then() calls is to use await instead of .then(), but that | ||
// should be the topic of a different ESLint rule. This rule does catch legitimate issues, but | ||
// as code is modernized with `async` and `await`, this rule will become less relevant. | ||
'promise/no-nesting': 'off', | ||
'quote-props': ['error', 'consistent-as-needed'], | ||
'quotes': ['error', 'single', {avoidEscape: true}], | ||
'rest-spread-spacing': 'error', | ||
'semi': 'error', | ||
'semi-spacing': 'error', | ||
'semi-style': 'error', | ||
'space-before-blocks': 'error', | ||
'space-before-function-paren': [ | ||
'error', | ||
{anonymous: 'always', asyncArrow: 'always', named: 'never'}, | ||
], | ||
'space-in-parens': 'error', | ||
'space-infix-ops': 'error', | ||
'space-unary-ops': ['error', {words: true, nonwords: false}], | ||
'spaced-comment': 'error', | ||
'strict': ['error', 'global'], | ||
'switch-colon-spacing': 'error', | ||
'template-curly-spacing': 'error', | ||
'template-tag-spacing': 'error', | ||
}, | ||
}; |
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,74 @@ | ||
name: Node.js Package | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node_version: | ||
- 12 | ||
- 14 | ||
- 16 | ||
name: Test Node.js v${{matrix.node_version}} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{matrix.node_version}} | ||
- run: npm ci | ||
- run: npm test | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{matrix.node_version}} | ||
- run: npm ci | ||
- run: npm run lint | ||
|
||
publish-npm: | ||
if: github.event_name == 'push' | ||
needs: | ||
- test | ||
- lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 12 | ||
registry-url: https://registry.npmjs.org/ | ||
- name: Bump version (patch) | ||
run: | | ||
LATEST_TAG=$(git describe --tags --abbrev=0) || exit 1 | ||
NEW_COMMITS=$(git rev-list --count "${LATEST_TAG}"..) || exit 1 | ||
[ "${NEW_COMMITS}" -gt 0 ] || exit 0 | ||
git config user.name 'github-actions[bot]' | ||
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
npm ci | ||
npm version patch | ||
git push --follow-tags | ||
# `npm publish` must come after `git push` otherwise there is a race | ||
# condition: If two PRs are merged back-to-back then master/main will be | ||
# updated with the commits from the second PR before the first PR's | ||
# workflow has a chance to push the commit generated by `npm version | ||
# patch`. This causes the first PR's `git push` step to fail after the | ||
# package has already been published, which in turn will cause all future | ||
# workflow runs to fail because they will all attempt to use the same | ||
# already-used version number. By running `npm publish` after `git push`, | ||
# back-to-back merges will cause the first merge's workflow to fail but | ||
# the second's will succeed. | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
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,2 @@ | ||
*.dirty | ||
node_modules |
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,8 @@ | ||
language: node_js | ||
arch: | ||
- amd64 | ||
- ppc64le | ||
node_js: | ||
- "stable" | ||
- "12" | ||
- "14" |
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 @@ | ||
Copyright (c) 2010 Debuggable Limited <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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 @@ | ||
test: | ||
npm test | ||
|
||
benchmark-v8: | ||
@find benchmark/v8/*.js | xargs -n 1 -t node | ||
|
||
benchmark-php: | ||
@find benchmark/php/*.php | xargs -n 1 -t php | ||
|
||
benchmark-dirty: | ||
@find benchmark/dirty/*.js | xargs -n 1 -t node | ||
|
||
benchmark-all: benchmark-v8 benchmark-php benchmark-dirty | ||
benchmark: benchmark-dirty | ||
|
||
clean: | ||
@find . -name *.dirty | xargs rm | ||
|
||
.PHONY: test benchmark |
Oops, something went wrong.