forked from estools/escodegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'eslint-npm' into eslint-npm-full; also adds linting to …
…recent adds and fixes regression (line 959) introduced in cf9a7b8 * eslint-npm: - npm: update estraverse - npm: update devDeps. - npm: Update package-lock version - npm: update devDeps. - npm: Update package-lock version - Linting: Temporarily disable most linting, with a few fixes - Breaking change: Remove bower-registry-client build (bower deprecated) - Update: Use new SourceMapConsumer API in test - Build: Provide browserified builds with npm package - Travis: Drop 4, 6, 8; Add 10, 12, 14; check build - Maintenance: Add `.editorconfig` - Docs: Use fenced code blocks in README (for syntax highlighting) - npm: Add `bugs`, `keywords`, change from `maintainers` to `authors`/`contributors` - npm: Restore `optionator` to a regular dep. (used in published binary file) - npm: Drop unused semver, minimist - npm: Bump deps. (estraverse, optionator, optional source-map potentially breaking) and devDeps. - npm: Drop bluebird in favor of ES Promises - npm: Use more recently maintained browserify + uglifyify - npm: Replace linting and testing scripts in Gulpfile with npm scripts Add more optional-chaining tests Test logical assignments Implement coalescing code generation Support BigInt syntax Update gulpfile and dependencies Version 2.0.0 add support for optional chaining (estools#412) Update .gitattributes drop support for node <6 (estools#419) # Conflicts: # .eslintignore # .eslintrc.js # .gitignore # escodegen.js.map # package-lock.json # package.json # src/escodegen.js # test/source-map.js # tools/release.js
- Loading branch information
Showing
22 changed files
with
11,861 additions
and
2,445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
test/3rdparty/**/* -crlf -diff | ||
# don't collapse diffs of test expectations | ||
test/compare-*/*.expected.min.js -linguist-generated |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com> | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'), | ||
acorn = require('acorn'), | ||
escodegen = require('./loader'), | ||
chai = require('chai'), | ||
chaiExclude = require('chai-exclude'); | ||
|
||
chai.use(chaiExclude); | ||
|
||
function test(code, expected) { | ||
const options = { | ||
ranges: false, | ||
locations: false, | ||
ecmaVersion: 11 | ||
}; | ||
|
||
const tree = acorn.parse(code, options); | ||
|
||
// for UNIX text comment | ||
const actual = escodegen.generate(tree); | ||
const actualTree = acorn.parse(actual, options); | ||
|
||
expect(actual).to.be.equal(expected); | ||
expect(tree).excludingEvery(['start', 'end', 'raw']).to.deep.equal(actualTree); | ||
} | ||
|
||
function testMin(code, expected) { | ||
const options = { | ||
ranges: false, | ||
locations: false, | ||
ecmaVersion: 11 | ||
}; | ||
|
||
const tree = acorn.parse(code, options); | ||
|
||
// for UNIX text comment | ||
const actual = `${escodegen.generate(tree, { | ||
format: escodegen.FORMAT_MINIFY, | ||
raw: false | ||
}).replace(/[\n\r]$/, '')}\n`; | ||
const actualTree = acorn.parse(actual, options); | ||
|
||
expect(actual).to.be.equal(expected); | ||
expect(tree).excludingEvery(['start', 'end', 'raw']).to.deep.equal(actualTree); | ||
} | ||
|
||
describe('compare acorn es2020 test', function () { | ||
fs.readdirSync(`${__dirname}/compare-acorn-es2020`).sort().forEach(function(file) { | ||
if (/\.js$/.test(file) && !/expected\.js$/.test(file) && !/expected\.min\.js$/.test(file)) { | ||
it(file, function () { | ||
const exp = file.replace(/\.js$/, '.expected.js'); | ||
const min = file.replace(/\.js$/, '.expected.min.js'); | ||
const code = fs.readFileSync(`${__dirname}/compare-acorn-es2020/${file}`, 'utf-8'); | ||
let expected = fs.readFileSync(`${__dirname}/compare-acorn-es2020/${exp}`, 'utf-8'); | ||
test(code, expected); | ||
if (fs.existsSync(`${__dirname}/compare-acorn-es2020/${min}`)) { | ||
expected = fs.readFileSync(`${__dirname}/compare-acorn-es2020/${min}`, 'utf-8'); | ||
testMin(code, expected); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
/* vim: set sw=4 ts=4 et tw=80 : */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
2000n + 30; | ||
20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n + 30; | ||
-20000000000000000000000000000n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2000n+30;20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n+30;-20000000000000000000000000000n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (C) 2020 Apple Inc. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
2000n + 30; | ||
20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n + 30; | ||
-20000000000000000000000000000n; |
Oops, something went wrong.