From 49db876907325d85157994f7d715604418f4849e Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Wed, 29 Apr 2020 16:23:58 +0800 Subject: [PATCH] - Update to Unicoode 13 - 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` --- .editorconfig | 18 ++++++++++++++++ .npmrc | 1 + lib/keyword.js | 16 +++++++------- package.json | 34 ++++++++++++++++++------------ test/ast.coffee | 1 - test/code.coffee | 1 - test/keyword.coffee | 1 - tools/generate-identifier-regex.js | 2 +- 8 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 .editorconfig create mode 100644 .npmrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d83d722 --- /dev/null +++ b/.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 diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..c1ca392 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +package-lock = false diff --git a/lib/keyword.js b/lib/keyword.js index 13c8c6a..6cee3a5 100644 --- a/lib/keyword.js +++ b/lib/keyword.js @@ -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; @@ -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); } diff --git a/package.json b/package.json index cebdd1b..4b9f42b 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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" } } diff --git a/test/ast.coffee b/test/ast.coffee index 021a7cd..94524c5 100644 --- a/test/ast.coffee +++ b/test/ast.coffee @@ -22,7 +22,6 @@ 'use strict' -expect = require('chai').expect esutils = require '../' EMPTY = {type: 'EmptyStatement'} diff --git a/test/code.coffee b/test/code.coffee index d0eed6f..d077cc6 100644 --- a/test/code.coffee +++ b/test/code.coffee @@ -22,7 +22,6 @@ 'use strict' -expect = require('chai').expect esutils = require '../' describe 'code', -> diff --git a/test/keyword.coffee b/test/keyword.coffee index 9fef055..32fe68d 100644 --- a/test/keyword.coffee +++ b/test/keyword.coffee @@ -22,7 +22,6 @@ 'use strict' -expect = require('chai').expect esutils = require '../' KW = [ diff --git a/tools/generate-identifier-regex.js b/tools/generate-identifier-regex.js index 2aef1f2..c803b8d 100644 --- a/tools/generate-identifier-regex.js +++ b/tools/generate-identifier-regex.js @@ -4,7 +4,7 @@ const regenerate = require('regenerate'); // Which Unicode version should be used? -const version = '9.0.0'; +const version = '13.0.0'; // Set up a shorthand function to import Unicode data. const get = function(what) {