Skip to content

Commit c959d4f

Browse files
author
Peter Marton
committed
feat(nerror): initial commit
0 parents  commit c959d4f

29 files changed

+4033
-0
lines changed

.eslintrc.js

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
'use strict';
2+
3+
module.exports = {
4+
// eslint: recommended automatically enables most/all rules from the
5+
// possible errors section and more:
6+
// http://eslint.org/docs/rules/#possible-errors
7+
extends: ['plugin:prettier/recommended'],
8+
env: {
9+
browser: false,
10+
node: true,
11+
es6: true,
12+
mocha: true
13+
},
14+
plugins: ['prettier'],
15+
rules: {
16+
'prettier/prettier': 'error',
17+
18+
// possible errors
19+
'no-cond-assign': ['error'],
20+
'no-constant-condition': ['error'],
21+
'no-control-regex': ['error'],
22+
'no-debugger': ['error'],
23+
'no-dupe-args': ['error'],
24+
'no-dupe-keys': ['error'],
25+
'no-duplicate-case': ['error'],
26+
'no-empty': ['error'],
27+
'no-empty-character-class': ['error'],
28+
'no-ex-assign': ['error'],
29+
'no-extra-boolean-cast': ['error'],
30+
'no-extra-semi': ['error'],
31+
'no-func-assign': ['error'],
32+
// this is for variable hoisting, not necessary if we use block scoped declarations
33+
// "no-inner-declarations": ["error", "both" ],
34+
'no-invalid-regexp': ['error'],
35+
'no-irregular-whitespace': ['error'],
36+
'no-reserved-keys': ['off'],
37+
'no-regex-spaces': ['error'],
38+
'no-sparse-arrays': ['error'],
39+
'no-unreachable': ['error'],
40+
'no-unsafe-negation': ['error'],
41+
'use-isnan': ['error'],
42+
'valid-jsdoc': [
43+
'error',
44+
{
45+
requireReturnDescription: false
46+
}
47+
],
48+
'valid-typeof': ['error'],
49+
50+
// best practices
51+
'array-callback-return': ['error'],
52+
'block-scoped-var': ['error'],
53+
'class-methods-use-this': ['error'],
54+
complexity: ['warn'],
55+
'consistent-return': ['error'],
56+
curly: ['error'],
57+
'default-case': ['error'],
58+
'dot-notation': ['error', { allowKeywords: true }],
59+
eqeqeq: ['error'],
60+
'guard-for-in': ['error'],
61+
'no-alert': ['error'],
62+
'no-caller': ['error'],
63+
'no-case-declarations': ['error'],
64+
'no-div-regex': ['error'],
65+
'no-empty-function': ['error'],
66+
'no-empty-pattern': ['error'],
67+
'no-eq-null': ['error'],
68+
'no-eval': ['error'],
69+
'no-extend-native': ['error'],
70+
'no-extra-bind': ['error'],
71+
'no-extra-label': ['error'],
72+
'no-fallthrough': ['error'],
73+
'no-floating-decimal': ['error'],
74+
'no-global-assign': ['error'],
75+
'no-implicit-coercion': ['error'],
76+
'no-implied-eval': ['error'],
77+
'no-iterator': ['error'],
78+
'no-labels': ['error'],
79+
'no-lone-blocks': ['error'],
80+
'no-loop-func': ['error'],
81+
'no-magic-numbers': ['off'],
82+
'no-multi-spaces': ['off'],
83+
'no-new': ['error'],
84+
'no-new-func': ['error'],
85+
'no-new-wrappers': ['error'],
86+
'no-octal': ['error'],
87+
'no-octal-escape': ['error'],
88+
'no-param-reassign': ['error'],
89+
'no-proto': ['error'],
90+
'no-redeclare': ['error'],
91+
'no-return-assign': ['error'],
92+
'no-script-url': ['error'],
93+
'no-self-assign': ['error'],
94+
'no-self-compare': ['error'],
95+
'no-sequences': ['error'],
96+
'no-throw-literal': ['error'],
97+
'no-unmodified-loop-condition': ['error'],
98+
'no-unused-expressions': ['error'],
99+
'no-unused-labels': ['error'],
100+
'no-useless-call': ['error'],
101+
'no-useless-concat': ['error'],
102+
'no-var': ['error'],
103+
'no-void': ['error'],
104+
'no-warning-comments': ['warn'],
105+
'no-with': ['error'],
106+
'prefer-const': ['error'],
107+
'wrap-iife': ['error'],
108+
yoda: ['error', 'never'],
109+
110+
// strict mode
111+
strict: ['error', 'global'],
112+
113+
// variables
114+
'no-catch-shadow': ['error'],
115+
'no-delete-var': ['error'],
116+
'no-shadow': ['error'],
117+
'no-shadow-restricted-names': ['error'],
118+
'no-undef': ['error'],
119+
'no-undef-init': ['error'],
120+
'no-unused-vars': ['error', { vars: 'all', args: 'none' }],
121+
'no-use-before-define': ['error', 'nofunc'],
122+
123+
// node.js
124+
'callback-return': [
125+
'error',
126+
['callback', 'cb', 'cb1', 'cb2', 'cb3', 'next', 'innerCb', 'done']
127+
],
128+
'global-require': ['error'],
129+
'handle-callback-err': ['error', '^.*(e|E)rr'],
130+
'no-mixed-requires': ['error'],
131+
'no-new-require': ['error'],
132+
'no-path-concat': ['error'],
133+
'no-process-exit': ['error']
134+
}
135+
};

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# OS generated files #
2+
######################
3+
.DS_Store
4+
.DS_Store?
5+
._*
6+
.Spotlight-V100
7+
.Trashes
8+
ehthumbs.db
9+
Thumbs.db
10+
11+
/node_modules/
12+
npm-debug.log
13+
yarn.lock
14+
package-lock.json
15+
16+
# VIM viles #
17+
#############
18+
[._]*.s[a-w][a-z]
19+
[._]s[a-w][a-z]
20+
*.un~
21+
Session.vim
22+
.netrwhist
23+
*~
24+
25+
# Unit Test Coverage #
26+
######################
27+
coverage/
28+
.nyc_output/
29+
30+
docs

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.githooks

.prettierrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
module.exports = {
4+
singleQuote: true,
5+
printWidth: 80,
6+
tabWidth: 4,
7+
semi: true,
8+
arrowParens: 'always'
9+
};

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- '8'
5+
- '10'
6+
- "lts/*" # Active LTS release
7+
- "node" # Latest stable release

AUTHORS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file lists all individuals having contributed content to the repository.
2+
# For how it is generated, see `scripts/generate-authors.sh`.
3+
4+
Alex Liu <DonutEspresso@users.noreply.github.com>
5+
Peter Marton <email@martonpeter.com>
6+
Peter Marton <pmarton@netflix.com>
7+
Joyent
8+
David Pacheco
9+
Trent Mick
10+
cburroughs
11+
Simen Bekkhus
12+
Samer Masterson

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019, AUTHORS. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE

Makefile

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#
2+
# Directories
3+
#
4+
ROOT_SLASH := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
5+
ROOT := $(patsubst %/,%,$(ROOT_SLASH))
6+
LIB := $(ROOT)/lib
7+
TEST := $(ROOT)/test
8+
TOOLS := $(ROOT)/tools
9+
GITHOOKS_SRC := $(TOOLS)/githooks
10+
GITHOOKS_DEST := $(ROOT)/.git/hooks
11+
12+
13+
#
14+
# Generated Files & Directories
15+
#
16+
NODE_MODULES := $(ROOT)/node_modules
17+
NODE_BIN := $(NODE_MODULES)/.bin
18+
COVERAGE := $(ROOT)/.nyc_output
19+
COVERAGE_RES := $(ROOT)/coverage
20+
YARN_LOCK := $(ROOT)/yarn.lock
21+
PACKAGE_LOCK := $(ROOT)/package-lock.json
22+
23+
24+
#
25+
# Tools and binaries
26+
#
27+
DOCUMENT := $(NODE_BIN)/documentation
28+
NPM := npm
29+
YARN := yarn
30+
ESLINT := $(NODE_BIN)/eslint
31+
MOCHA := $(NODE_BIN)/mocha
32+
NYC := $(NODE_BIN)/nyc
33+
PRETTIER := $(NODE_BIN)/prettier
34+
UNLEASH := $(NODE_BIN)/unleash
35+
CONVENTIONAL_RECOMMENDED_BUMP := $(NODE_BIN)/conventional-recommended-bump
36+
COVERAGE_BADGE := $(TOOLS)/coverageBadge.js
37+
38+
39+
#
40+
# Files and globs
41+
#
42+
PACKAGE_JSON := $(ROOT)/package.json
43+
API_MD := $(ROOT)/api.md
44+
GITHOOKS := $(wildcard $(GITHOOKS_SRC)/*)
45+
TEST_ENTRY := $(ROOT)/test/index.js
46+
ALL_FILES := $(shell find $(ROOT) \
47+
-not \( -path $(NODE_MODULES) -prune \) \
48+
-not \( -path $(COVERAGE) -prune \) \
49+
-not \( -path $(COVERAGE_RES) -prune \) \
50+
-name '*.js' -type f)
51+
TEST_FILES := $(shell find $(TEST) -name '*.js' -type f)
52+
53+
#
54+
# Targets
55+
#
56+
57+
$(NODE_MODULES): $(PACKAGE_JSON) ## Install node_modules
58+
@$(YARN)
59+
@touch $(NODE_MODULES)
60+
61+
62+
.PHONY: authors
63+
authors:
64+
@ ./scripts/generate-authors.sh
65+
66+
.PHONY: docs
67+
docs: $(DOCUMENT) $(ALL_FILES)
68+
@$(DOCUMENT) build $(LIB) -f md -o $(API_MD)
69+
70+
71+
.PHONY: help
72+
help:
73+
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) \
74+
| sort | awk 'BEGIN {FS = ":.*?## "}; \
75+
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
76+
77+
78+
.PHONY: githooks
79+
githooks: $(GITHOOKS) ## Symlink githooks
80+
@$(foreach hook,\
81+
$(GITHOOKS),\
82+
ln -sf $(hook) $(GITHOOKS_DEST)/$(hook##*/);\
83+
)
84+
85+
86+
.PHONY: release-dry
87+
release-dry: $(NODE_MODULES) ## Dry run of `release` target
88+
$(UNLEASH) -d --type=$(shell $(CONVENTIONAL_RECOMMENDED_BUMP) -p angular)
89+
90+
91+
.PHONY: release
92+
release: $(NODE_MODULES) ## Versions, tags, and updates changelog based on commit messages
93+
$(UNLEASH) --type=$(shell $(CONVENTIONAL_RECOMMENDED_BUMP) -p angular)
94+
95+
96+
.PHONY: lint
97+
lint: $(NODE_MODULES) $(ESLINT) $(ALL_FILES) ## Run lint checker (eslint).
98+
@$(ESLINT) $(ALL_FILES)
99+
100+
101+
.PHONY: lint-fix
102+
lint-fix: $(NODE_MODULES) $(PRETTIER) $(ALL_FILES) ## Reprint code (prettier, eslint).
103+
@$(PRETTIER) --write $(ALL_FILES)
104+
@$(ESLINT) --fix $(ALL_FILES)
105+
106+
107+
.PHONY: security
108+
security: $(NODE_MODULES) ## Check for dependency vulnerabilities.
109+
@$(NPM) install --package-lock-only
110+
@$(NPM) audit
111+
112+
113+
.PHONY: prepush
114+
prepush: $(NODE_MODULES) lint coverage security ## Git pre-push hook task. Run before committing and pushing.
115+
116+
117+
.PHONY: test
118+
test: $(NODE_MODULES) $(MOCHA) ## Run unit tests.
119+
@$(MOCHA) -R spec --full-trace --no-exit --no-timeouts $(TEST_FILES)
120+
121+
122+
.PHONY: coverage
123+
coverage: $(NODE_MODULES) $(NYC) $(COVERAGE_BADGE) ## Run unit tests with coverage reporting. Generates reports into /coverage.
124+
@$(NYC) --reporter=json-summary --reporter=html --reporter=text make test
125+
@$(COVERAGE_BADGE)
126+
127+
128+
.PHONY: clean
129+
clean: ## Cleans unit test coverage files and node_modules.
130+
@rm -rf $(NODE_MODULES) $(COVERAGE) $(COVERAGE_RES) $(YARN_LOCK) $(PACKAGE_LOCK)
131+
132+
133+
#
134+
## Debug -- print out a a variable via `make print-FOO`
135+
#
136+
print-% : ; @echo $* = $($*)

OSSMETADATA

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
osslifecycle=active

0 commit comments

Comments
 (0)