Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Esm eslint #34

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
["@babel/preset-env"]
]
}
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.json]
indent_size = 2

[*.yml]
indent_size = 2
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
dist

!.eslintrc.js
coverage

src/es5-identifier.js
src/es6-identifier.js
48 changes: 48 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true,
node: true
},
extends: 'eslint:recommended',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
overrides: [{
files: '.eslintrc.js',
parserOptions: {
sourceType: 'script'
},
rules: {
strict: 'error'
}
}, {
files: 'test/**',
globals: {
expect: true
},
env: {
mocha: true
}
}],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018
},
rules: {
semi: ['error'],
indent: ['error', 4, { SwitchCase: 1 }],
'prefer-const': ['error'],
'no-var': ['error'],
'prefer-destructuring': ['error'],
'object-shorthand': ['error'],
'object-curly-spacing': ['error', 'always'],
quotes: ['error', 'single'],
'quote-props': ['error', 'as-needed'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'prefer-template': ['error']
}
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
dist
coverage
16 changes: 0 additions & 16 deletions .jshintrc

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock = false
9 changes: 3 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
language: node_js
node_js:
- "0.10"
- "0.11"

matrix:
allow_failures:
- node_js: "0.11"
- 12
- 14
- 16
70 changes: 35 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ utility box for ECMAScript language tools.

## API

## `ast`
## `ast`

### `ast.isExpression(node)`
### `ast.isExpression(node)`

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

### `ast.isStatement(node)`
### `ast.isStatement(node)`

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

### `ast.isIterationStatement(node)`
### `ast.isIterationStatement(node)`

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

### `ast.isSourceElement(node)`
### `ast.isSourceElement(node)`

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

### `ast.trailingStatement(node)`
### `ast.trailingStatement(node)`

Returns `Statement?` if `node` has trailing `Statement`.
```js
Expand All @@ -35,7 +35,7 @@ if (cond)
```
When taking this `IfStatement`, returns `consequent;` statement.

### `ast.isProblematicIfStatement(node)`
### `ast.isProblematicIfStatement(node)`

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.
```js
Expand All @@ -54,101 +54,101 @@ Returns `true` if `node` is a problematic `IfStatement`. If `node` is a problema
The above node cannot be represented as a JavaScript code, since the top level `else` alternate belongs to an inner `IfStatement`.


## `code`
## `code`

### `code.isDecimalDigit(code)`
### `code.isDecimalDigit(code)`

Return `true` if provided code is decimal digit.

### `code.isHexDigit(code)`
### `code.isHexDigit(code)`

Return `true` if provided code is hexadecimal digit.

### `code.isOctalDigit(code)`
### `code.isOctalDigit(code)`

Return `true` if provided code is octal digit.

### `code.isWhiteSpace(code)`
### `code.isWhiteSpace(code)`

Return `true` if provided code is white space.
Return `true` if provided code is white space.
White space characters are formally defined in ECMA262.

### `code.isLineTerminator(code)`
### `code.isLineTerminator(code)`

Return `true` if provided code is line terminator.
Return `true` if provided code is line terminator.
Line terminator characters are formally defined in ECMA262.

### `code.isIdentifierStart(code)`
### `code.isIdentifierStart(code)`

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

### `code.isIdentifierPart(code)`
### `code.isIdentifierPart(code)`

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

## `keyword`
## `keyword`

### `keyword.isKeywordES5(id, strict)`
### `keyword.isKeywordES5(id, strict)`

Returns `true` if provided identifier string is a Keyword or Future Reserved Word
in ECMA262 edition 5.1.
in ECMA262 edition 5.1.
They are formally defined in ECMA262 sections
[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),
respectively.
respectively.
If the `strict` flag is truthy, this function additionally checks whether
`id` is a `Keyword` or `FutureReservedWord` under strict mode.

### `keyword.isKeywordES6(id, strict)`
### `keyword.isKeywordES6(id, strict)`

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

### `keyword.isReservedWordES5(id, strict)`
### `keyword.isReservedWordES5(id, strict)`

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

### `keyword.isReservedWordES6(id, strict)`
### `keyword.isReservedWordES6(id, strict)`

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

### `keyword.isRestrictedWord(id)`
### `keyword.isRestrictedWord(id)`

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

### `keyword.isIdentifierNameES5(id)`
### `keyword.isIdentifierNameES5(id)`

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

### `keyword.isIdentifierNameES6(id)`
### `keyword.isIdentifierNameES6(id)`

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

### `keyword.isIdentifierES5(id, strict)`
### `keyword.isIdentifierES5(id, strict)`

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

### `keyword.isIdentifierES6(id, strict)`
### `keyword.isIdentifierES6(id, strict)`

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