Skip to content

Commit a5b1277

Browse files
authored
Merge pull request #77 from redbug312/migrate-to-es6-module
Migrate to ES6 Module
2 parents 09859e5 + 6286546 commit a5b1277

19 files changed

Lines changed: 6044 additions & 3486 deletions

.eslintignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.eslintrc.yml

Lines changed: 18 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,21 @@
1-
env:
2-
node: true
3-
browser: false
4-
es6: false
1+
extends: standard
52

6-
rules:
7-
accessor-pairs: 2
8-
array-bracket-spacing: [ 2, "always", { "singleValue": true, "objectsInArrays": true, "arraysInArrays": true } ]
9-
block-scoped-var: 2
10-
block-spacing: 2
11-
brace-style: [ 2, '1tbs', { allowSingleLine: true } ]
12-
# Postponed
13-
#callback-return: 2
14-
comma-dangle: 2
15-
comma-spacing: 2
16-
comma-style: 2
17-
computed-property-spacing: [ 2, never ]
18-
consistent-this: [ 2, self ]
19-
consistent-return: 2
20-
# ? change to multi
21-
curly: [ 2, 'multi-line' ]
22-
dot-notation: 2
23-
eol-last: 2
24-
eqeqeq: 2
25-
func-style: [ 2, declaration ]
26-
# Postponed
27-
#global-require: 2
28-
guard-for-in: 2
29-
handle-callback-err: 2
3+
overrides:
4+
- files: ["*.mjs"]
5+
rules:
6+
no-restricted-globals: [2, require, __dirname]
7+
- files: ["test/**"]
8+
env:
9+
mocha: true
10+
- files: ["lib/**", "index.mjs"]
11+
parserOptions:
12+
ecmaVersion: 2015
3013

31-
indent: [ 2, 2, { VariableDeclarator: { var: 2, let: 2, const: 3 }, SwitchCase: 1 } ]
14+
ignorePatterns:
15+
- demo/
16+
- dist/
17+
- benchmark/extra/
3218

33-
# key-spacing: [ 2, { "align": "value" } ]
34-
keyword-spacing: 2
35-
linebreak-style: 2
36-
max-depth: [ 1, 6 ]
37-
max-nested-callbacks: [ 1, 4 ]
38-
# string can exceed 80 chars, but should not overflow github website :)
39-
max-len: [ 2, 120, 1000 ]
40-
new-cap: 2
41-
new-parens: 2
42-
# Postponed
43-
#newline-after-var: 2
44-
no-alert: 2
45-
no-array-constructor: 2
46-
# inconsisent rule with markdown-it, since bitwise operations are intentionally used.
47-
# no-bitwise: 2
48-
no-caller: 2
49-
#no-case-declarations: 2
50-
no-catch-shadow: 2
51-
no-cond-assign: 2
52-
no-console: 1
53-
no-constant-condition: 2
54-
#no-control-regex: 2
55-
no-debugger: 2
56-
no-delete-var: 2
57-
no-div-regex: 2
58-
no-dupe-args: 2
59-
no-dupe-keys: 2
60-
no-duplicate-case: 2
61-
no-else-return: 2
62-
# Tend to drop
63-
# no-empty: 1
64-
no-empty-character-class: 2
65-
no-empty-pattern: 2
66-
no-eq-null: 2
67-
no-eval: 2
68-
no-ex-assign: 2
69-
no-extend-native: 2
70-
no-extra-bind: 2
71-
no-extra-boolean-cast: 2
72-
no-extra-semi: 2
73-
no-fallthrough: 2
74-
no-floating-decimal: 2
75-
no-func-assign: 2
76-
# Postponed
77-
#no-implicit-coercion: [2, { "boolean": true, "number": true, "string": true } ]
78-
no-implied-eval: 2
79-
no-inner-declarations: 2
80-
no-invalid-regexp: 2
81-
no-irregular-whitespace: 2
82-
no-iterator: 2
83-
no-label-var: 2
84-
no-labels: 2
85-
no-lone-blocks: 2
86-
no-lonely-if: 2
87-
no-loop-func: 2
88-
no-mixed-requires: 2
89-
no-mixed-spaces-and-tabs: 2
90-
# Postponed
91-
#no-native-reassign: 2
92-
no-negated-in-lhs: 2
93-
# Postponed
94-
#no-nested-ternary: 2
95-
no-new: 2
96-
no-new-func: 2
97-
no-new-object: 2
98-
no-new-require: 2
99-
no-new-wrappers: 2
100-
no-obj-calls: 2
101-
no-octal: 2
102-
no-octal-escape: 2
103-
no-path-concat: 2
104-
no-proto: 2
105-
no-redeclare: 2
106-
# Postponed
107-
#no-regex-spaces: 2
108-
no-return-assign: 2
109-
no-self-compare: 2
110-
no-sequences: 2
111-
no-shadow: 2
112-
no-shadow-restricted-names: 2
113-
no-sparse-arrays: 2
114-
no-trailing-spaces: 2
115-
no-undef: 2
116-
no-undef-init: 2
117-
no-undefined: 2
118-
no-unexpected-multiline: 2
119-
no-unreachable: 2
120-
no-unused-expressions: 2
121-
no-unused-vars: 2
122-
no-use-before-define: 2
123-
no-void: 2
124-
no-with: 2
125-
object-curly-spacing: [ 2, always, { "objectsInObjects": true, "arraysInObjects": true } ]
126-
operator-assignment: 1
127-
# Postponed
128-
#operator-linebreak: [ 2, after ]
129-
semi: 2
130-
semi-spacing: 2
131-
space-before-function-paren: [ 2, { "anonymous": "always", "named": "never" } ]
132-
space-in-parens: [ 2, never ]
133-
space-infix-ops: 2
134-
space-unary-ops: 2
135-
# Postponed
136-
#spaced-comment: [ 1, always, { exceptions: [ '/', '=' ] } ]
137-
strict: [ 2, global ]
138-
quotes: [ 2, single, avoid-escape ]
139-
quote-props: [ 1, 'as-needed', { "keywords": true } ]
140-
radix: 2
141-
use-isnan: 2
142-
valid-typeof: 2
143-
yoda: [ 2, never, { "exceptRange": true } ]
19+
rules:
20+
camelcase: 0
21+
no-multi-spaces: 0

.github/workflows/node.yml

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,46 @@ name: Node.js
22

33
on:
44
push:
5-
branches: [ master, '**', '!wip-**' ]
65
pull_request:
7-
branches: [ master ]
6+
release:
7+
types: [published]
88

99
jobs:
10-
test-ci-job:
10+
build:
1111
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
node-version: [ '12', '14' ]
1512
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-node@v2
18-
with:
19-
node-version: ${{ matrix.node-version }}
20-
- run: make report-coveralls
21-
- uses: coverallsapp/github-action@master
22-
with:
23-
github-token: ${{ secrets.GITHUB_TOKEN }}
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
- name: Setup Node.js 18
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '18'
19+
- name: Install dependencies
20+
run: npm install --save-dev
21+
- name: Run audit task
22+
run: make audit
23+
- name: Run lint task
24+
run: make lint
25+
- name: Run test task
26+
run: make test
27+
- name: Run minify task
28+
run: make minify
29+
- name: Upload minified code as artifact
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: dist
33+
path: dist # Or your Rollup output directory
34+
release:
35+
runs-on: ubuntu-latest
36+
needs: build
37+
if: github.event_name == 'release'
38+
steps:
39+
- name: Download Build Artifacts
40+
uses: actions/download-artifact@v4
41+
with:
42+
name: dist
43+
path: dist
44+
- name: Create GitHub Release
45+
uses: softprops/action-gh-release@v2
46+
with:
47+
files: dist/* # Upload files from your build output

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
.nyc_output/
2-
node_modules/
31
bower_components/
42
coverage/
3+
node_modules/
4+
5+
docs/
6+
biome.json

Makefile

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1-
.PHONY: lint test coverage report-coveralls browserify
2-
31
MODULE_PATH := ./node_modules/.bin
4-
export PATH := ${MODULE_PATH}:$(PATH)
2+
ENV ?= PATH=$(MODULE_PATH):$(PATH)
53

4+
.PHONY: all
5+
all: test lint
66

7-
${MODULE_PATH}: package.json
8-
npm install --save-dev
9-
touch $@ # update timestamp
7+
.PHONY: audit
8+
audit: $(MODULE_PATH)
9+
npm audit
1010

11+
.PHONY: lint
12+
lint: $(MODULE_PATH)
13+
$(ENV) eslint . --ignore-pattern docs
1114

12-
lint: ${MODULE_PATH}
13-
eslint . --ignore-pattern support
15+
.PHONY: test
16+
test: $(MODULE_PATH)
17+
$(ENV) c8 --exclude=dist --exclude=test --reporter=text --reporter=html --reporter=lcov mocha --bail
1418

15-
test: ${MODULE_PATH} lint
16-
nyc mocha
19+
.PHONY: fmt
20+
fmt: $(MODULE_PATH)
21+
$(ENV) eslint . --ignore-pattern docs --fix
1722

18-
coverage: ${MODULE_PATH} lint
19-
nyc report --reporter html
23+
.PHONY: doc
24+
doc: $(MODULE_PATH)
25+
$(ENV) jsdoc --configure jsdoc.json
2026

21-
report-coveralls: ${MODULE_PATH} lint
22-
# For coverage test. You can use `make coverage` on local.
23-
nyc --reporter=lcov mocha
27+
.PHONY: minify
28+
minify: $(MODULE_PATH)
29+
$(ENV) rollup --config
2430

25-
browserify: ${MODULE_PATH} lint test
26-
rollup -c support/rollup.config.js
31+
32+
$(MODULE_PATH): package.json
33+
npm install --save-dev
34+
touch $@ # update timestamp

bower.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)