Skip to content

Commit

Permalink
- Update to Unicoode 13; closes #27
Browse files Browse the repository at this point in the history
- Linting: As per latest jshint (define function before called)
- Testing: Use chai's `register-expect`
- npm: Update devDeps (including moving from `coffee-script` to non-deprecated `coffeescript`)
- npm: Simplify script running
- npm: Avoid adding `package-lock.json`
- npm: Update mocha per latest API
- npm: Add recommended package.json fields: keywords, bugs, dependencies and change to author/contributors
- Maintenance: Add `.editorconfig`
  • Loading branch information
brettz9 committed Apr 29, 2020
1 parent a825f91 commit 6281a63
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 27 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
@@ -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
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
package-lock = false
16 changes: 8 additions & 8 deletions lib/keyword.js
Expand Up @@ -43,14 +43,6 @@
}
}

function isKeywordES5(id, strict) {
// yield should not be treated as keyword under non-strict mode.
if (!strict && id === 'yield') {
return false;
}
return isKeywordES6(id, strict);
}

function isKeywordES6(id, strict) {
if (strict && isStrictModeReservedWordES6(id)) {
return true;
Expand Down Expand Up @@ -82,6 +74,14 @@
}
}

function isKeywordES5(id, strict) {
// yield should not be treated as keyword under non-strict mode.
if (!strict && id === 'yield') {
return false;
}
return isKeywordES6(id, strict);
}

function isReservedWordES5(id, strict) {
return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
}
Expand Down
34 changes: 20 additions & 14 deletions package.json
Expand Up @@ -2,6 +2,7 @@
"name": "esutils",
"description": "utility box for ECMAScript language tools",
"homepage": "https://github.com/estools/esutils",
"bugs": "https://github.com/estools/esutils/issues",
"main": "lib/utils.js",
"version": "2.0.4-dev",
"engines": {
Expand All @@ -15,30 +16,35 @@
"README.md",
"lib"
],
"maintainers": [
{
"name": "Yusuke Suzuki",
"email": "utatane.tea@gmail.com",
"web": "http://github.com/Constellation"
}
"keywords": [
"ecmascript"
],
"author": {
"name": "Yusuke Suzuki",
"email": "utatane.tea@gmail.com",
"web": "http://github.com/Constellation"
},
"contributors": [
"Brett Zamir"
],
"repository": {
"type": "git",
"url": "http://github.com/estools/esutils.git"
},
"dependencies": {},
"devDependencies": {
"chai": "~1.7.2",
"coffee-script": "~1.6.3",
"jshint": "2.6.3",
"mocha": "~2.2.1",
"regenerate": "~1.3.1",
"unicode-9.0.0": "~0.7.0"
"chai": "~4.2.0",
"coffeescript": "^2.5.1",
"jshint": "2.11.0",
"mocha": "~7.1.2",
"regenerate": "~1.4.0",
"unicode-13.0.0": "^0.8.0"
},
"license": "BSD-2-Clause",
"scripts": {
"test": "npm run-script lint && npm run-script unit-test",
"test": "npm run lint && npm run unit-test",
"lint": "jshint lib/*.js",
"unit-test": "mocha --compilers coffee:coffee-script -R spec",
"unit-test": "mocha --require chai/register-expect --require coffeescript/register test/**",
"generate-regex": "node tools/generate-identifier-regex.js"
}
}
1 change: 0 additions & 1 deletion test/ast.coffee
Expand Up @@ -22,7 +22,6 @@

'use strict'

expect = require('chai').expect
esutils = require '../'

EMPTY = {type: 'EmptyStatement'}
Expand Down
1 change: 0 additions & 1 deletion test/code.coffee
Expand Up @@ -22,7 +22,6 @@

'use strict'

expect = require('chai').expect
esutils = require '../'

describe 'code', ->
Expand Down
1 change: 0 additions & 1 deletion test/keyword.coffee
Expand Up @@ -22,7 +22,6 @@

'use strict'

expect = require('chai').expect
esutils = require '../'

KW = [
Expand Down
7 changes: 5 additions & 2 deletions tools/generate-identifier-regex.js
Expand Up @@ -4,11 +4,14 @@
const regenerate = require('regenerate');

// Which Unicode version should be used?
const version = '9.0.0';
const pkg = require('../package.json');
const dependencies = Object.keys(pkg.devDependencies);
const unicodeDep = dependencies.find((name) => /^unicode-\d/.test(name));
const version = unicodeDep.match(/[^\d]+(.+)$/)[1];

// Set up a shorthand function to import Unicode data.
const get = function(what) {
return require('unicode-' + version + '/' + what + '/code-points');
return require('unicode-' + version + '/' + what + '/code-points.js');
};

// Get the Unicode categories needed to construct the ES5 regex.
Expand Down

0 comments on commit 6281a63

Please sign in to comment.