Skip to content

Commit 5201b87

Browse files
committed
- Enhancement: Add ESM distribution, with module property in package.json
- Refactoring: Add Rollup/Babel/Terser - Build: Have generator file produce consumable source files directly rather than logging to console - Linting: Switch from JSHint to ESLint (using rules, e.g., `indent` and `prefer-const`, in place on other estools project) - Testing: Convert coffeescript test files to ES6 - Testing: Add nyc - Testing: Check unmatched high surrogates and full coverage for AST expressions (further true `isExpression` and `isStatement`'s and false `isProblematicIfStatement`), bringing to 100% coverage - Travis: Drop previous versions for 10, 12, 14 - Docs: Use heading nesting consistently; rmv trailing spaces
1 parent 6281a63 commit 5201b87

24 files changed

+1448
-1214
lines changed

.babelrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
["@babel/preset-env"]
4+
]
5+
}

.eslintignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
dist
3+
4+
!.eslintrc.js
5+
coverage
6+
7+
src/es5-identifier.js
8+
src/es6-identifier.js

.eslintrc.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
module.exports = {
3+
env: {
4+
browser: true,
5+
commonjs: true,
6+
es6: true,
7+
node: true
8+
},
9+
extends: 'eslint:recommended',
10+
globals: {
11+
Atomics: 'readonly',
12+
SharedArrayBuffer: 'readonly'
13+
},
14+
overrides: [{
15+
files: '.eslintrc.js',
16+
parserOptions: {
17+
sourceType: 'script'
18+
},
19+
rules: {
20+
strict: 'error'
21+
}
22+
}, {
23+
files: 'test/**',
24+
globals: {
25+
expect: true
26+
},
27+
env: {
28+
mocha: true
29+
}
30+
}],
31+
parserOptions: {
32+
sourceType: 'module',
33+
ecmaVersion: 2018
34+
},
35+
rules: {
36+
semi: ['error'],
37+
indent: ['error', 4, { SwitchCase: 1 }],
38+
'prefer-const': ['error'],
39+
'no-var': ['error'],
40+
'prefer-destructuring': ['error'],
41+
'object-shorthand': ['error'],
42+
'object-curly-spacing': ['error', 'always'],
43+
quotes: ['error', 'single'],
44+
'quote-props': ['error', 'as-needed'],
45+
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
46+
'prefer-template': ['error']
47+
}
48+
};

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
node_modules
2+
dist
3+
coverage

.jshintrc

-16
This file was deleted.

.travis.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
language: node_js
22
node_js:
3-
- "0.10"
4-
- "0.11"
5-
6-
matrix:
7-
allow_failures:
8-
- node_js: "0.11"
3+
- 10
4+
- 12
5+
- 14

README.md

+35-35
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ utility box for ECMAScript language tools.
44

55
## API
66

7-
## `ast`
7+
## `ast`
88

9-
### `ast.isExpression(node)`
9+
### `ast.isExpression(node)`
1010

1111
Returns `true` if `node` is an `Expression` as defined in ECMA262 edition 5.1 section
1212
[11](https://es5.github.io/#x11).
1313

14-
### `ast.isStatement(node)`
14+
### `ast.isStatement(node)`
1515

1616
Returns `true` if `node` is a `Statement` as defined in ECMA262 edition 5.1 section
1717
[12](https://es5.github.io/#x12).
1818

19-
### `ast.isIterationStatement(node)`
19+
### `ast.isIterationStatement(node)`
2020

2121
Returns `true` if `node` is an `IterationStatement` as defined in ECMA262 edition
2222
5.1 section [12.6](https://es5.github.io/#x12.6).
2323

24-
### `ast.isSourceElement(node)`
24+
### `ast.isSourceElement(node)`
2525

2626
Returns `true` if `node` is a `SourceElement` as defined in ECMA262 edition 5.1
2727
section [14](https://es5.github.io/#x14).
2828

29-
### `ast.trailingStatement(node)`
29+
### `ast.trailingStatement(node)`
3030

3131
Returns `Statement?` if `node` has trailing `Statement`.
3232
```js
@@ -35,7 +35,7 @@ if (cond)
3535
```
3636
When taking this `IfStatement`, returns `consequent;` statement.
3737

38-
### `ast.isProblematicIfStatement(node)`
38+
### `ast.isProblematicIfStatement(node)`
3939

4040
Returns `true` if `node` is a problematic `IfStatement`. If `node` is a problematic `IfStatement`, `node` cannot be represented as an one-to-one JavaScript code.
4141
```js
@@ -54,101 +54,101 @@ Returns `true` if `node` is a problematic `IfStatement`. If `node` is a problema
5454
The above node cannot be represented as a JavaScript code, since the top level `else` alternate belongs to an inner `IfStatement`.
5555

5656

57-
## `code`
57+
## `code`
5858

59-
### `code.isDecimalDigit(code)`
59+
### `code.isDecimalDigit(code)`
6060

6161
Return `true` if provided code is decimal digit.
6262

63-
### `code.isHexDigit(code)`
63+
### `code.isHexDigit(code)`
6464

6565
Return `true` if provided code is hexadecimal digit.
6666

67-
### `code.isOctalDigit(code)`
67+
### `code.isOctalDigit(code)`
6868

6969
Return `true` if provided code is octal digit.
7070

71-
### `code.isWhiteSpace(code)`
71+
### `code.isWhiteSpace(code)`
7272

73-
Return `true` if provided code is white space.
73+
Return `true` if provided code is white space.
7474
White space characters are formally defined in ECMA262.
7575

76-
### `code.isLineTerminator(code)`
76+
### `code.isLineTerminator(code)`
7777

78-
Return `true` if provided code is line terminator.
78+
Return `true` if provided code is line terminator.
7979
Line terminator characters are formally defined in ECMA262.
8080

81-
### `code.isIdentifierStart(code)`
81+
### `code.isIdentifierStart(code)`
8282

83-
Return `true` if provided code can be the first character of ECMA262 `Identifier`.
83+
Return `true` if provided code can be the first character of ECMA262 `Identifier`.
8484
They are formally defined in ECMA262.
8585

86-
### `code.isIdentifierPart(code)`
86+
### `code.isIdentifierPart(code)`
8787

88-
Return `true` if provided code can be the trailing character of ECMA262 `Identifier`.
88+
Return `true` if provided code can be the trailing character of ECMA262 `Identifier`.
8989
They are formally defined in ECMA262.
9090

91-
## `keyword`
91+
## `keyword`
9292

93-
### `keyword.isKeywordES5(id, strict)`
93+
### `keyword.isKeywordES5(id, strict)`
9494

9595
Returns `true` if provided identifier string is a Keyword or Future Reserved Word
96-
in ECMA262 edition 5.1.
96+
in ECMA262 edition 5.1.
9797
They are formally defined in ECMA262 sections
9898
[7.6.1.1](http://es5.github.io/#x7.6.1.1) and [7.6.1.2](http://es5.github.io/#x7.6.1.2),
99-
respectively.
99+
respectively.
100100
If the `strict` flag is truthy, this function additionally checks whether
101101
`id` is a `Keyword` or `FutureReservedWord` under strict mode.
102102

103-
### `keyword.isKeywordES6(id, strict)`
103+
### `keyword.isKeywordES6(id, strict)`
104104

105105
Returns `true` if provided identifier string is a `Keyword` or `FutureReservedWord`
106-
in ECMA262 edition 6.
106+
in ECMA262 edition 6.
107107
They are formally defined in ECMA262 sections
108108
[11.6.2.1](http://ecma-international.org/ecma-262/6.0/#sec-keywords) and
109109
[11.6.2.2](http://ecma-international.org/ecma-262/6.0/#sec-future-reserved-words),
110-
respectively.
110+
respectively.
111111
If the `strict` flag is truthy, this function additionally checks whether
112112
`id` is a `Keyword` or `FutureReservedWord` under strict mode.
113113

114-
### `keyword.isReservedWordES5(id, strict)`
114+
### `keyword.isReservedWordES5(id, strict)`
115115

116116
Returns `true` if provided identifier string is a `ReservedWord` in ECMA262 edition 5.1.
117117
They are formally defined in ECMA262 section [7.6.1](http://es5.github.io/#x7.6.1).
118118
If the `strict` flag is truthy, this function additionally checks whether `id`
119119
is a `ReservedWord` under strict mode.
120120

121-
### `keyword.isReservedWordES6(id, strict)`
121+
### `keyword.isReservedWordES6(id, strict)`
122122

123123
Returns `true` if provided identifier string is a `ReservedWord` in ECMA262 edition 6.
124124
They are formally defined in ECMA262 section [11.6.2](http://ecma-international.org/ecma-262/6.0/#sec-reserved-words).
125125
If the `strict` flag is truthy, this function additionally checks whether `id`
126126
is a `ReservedWord` under strict mode.
127127

128-
### `keyword.isRestrictedWord(id)`
128+
### `keyword.isRestrictedWord(id)`
129129

130130
Returns `true` if provided identifier string is one of `eval` or `arguments`.
131131
They are restricted in strict mode code throughout ECMA262 edition 5.1 and
132132
in ECMA262 edition 6 section [12.1.1](http://ecma-international.org/ecma-262/6.0/#sec-identifiers-static-semantics-early-errors).
133133

134-
### `keyword.isIdentifierNameES5(id)`
134+
### `keyword.isIdentifierNameES5(id)`
135135

136136
Return `true` if provided identifier string is an `IdentifierName` as specified in
137137
ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6).
138138

139-
### `keyword.isIdentifierNameES6(id)`
139+
### `keyword.isIdentifierNameES6(id)`
140140

141141
Return `true` if provided identifier string is an `IdentifierName` as specified in
142142
ECMA262 edition 6 section [11.6](http://ecma-international.org/ecma-262/6.0/#sec-names-and-keywords).
143143

144-
### `keyword.isIdentifierES5(id, strict)`
144+
### `keyword.isIdentifierES5(id, strict)`
145145

146146
Return `true` if provided identifier string is an `Identifier` as specified in
147-
ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6).
148-
If the `strict` flag is truthy, this function additionally checks whether `id`
147+
ECMA262 edition 5.1 section [7.6](https://es5.github.io/#x7.6).
148+
If the `strict` flag is truthy, this function additionally checks whether `id`
149149
is an `Identifier` under strict mode.
150150

151-
### `keyword.isIdentifierES6(id, strict)`
151+
### `keyword.isIdentifierES6(id, strict)`
152152

153153
Return `true` if provided identifier string is an `Identifier` as specified in
154154
ECMA262 edition 6 section [12.1](http://ecma-international.org/ecma-262/6.0/#sec-identifiers).

0 commit comments

Comments
 (0)