Bump eslint-plugin-import to avoid vulnerability in dependency

This commit is contained in:
Henry Mercer 2023-01-18 20:26:59 +00:00
parent 10695e6a20
commit ed9506bbaf
1660 changed files with 67726 additions and 27926 deletions

View file

@ -14,8 +14,18 @@ indent_style = space
indent_size = 2
max_line_length = off
[README.md]
indent_style = off
indent_size = off
max_line_length = off
[*.json]
max_line_length = off
[Makefile]
max_line_length = off
[coverage*/**/*]
indent_style = off
indent_size = off
max_line_length = off

View file

@ -1 +0,0 @@
coverage/

11
node_modules/is-callable/.eslintrc generated vendored
View file

@ -5,17 +5,6 @@
"rules": {
"id-length": 0,
"max-statements": [2, 14],
"max-statements-per-line": [2, { "max": 2 }],
"operator-linebreak": [2, "before"],
},
"overrides": [
{
"files": "test/**",
"rules": {
"no-throw-literal": 0,
},
},
],
}

View file

@ -1,14 +0,0 @@
workflow "Autorebase branch on merge commits" {
on = "push"
resolves = ["rebase"]
}
workflow "Autorebase PR on merge commits" {
on = "pull_request"
resolves = ["rebase"]
}
action "rebase" {
uses = "ljharb/rebase@latest"
secrets = ["GITHUB_TOKEN"]
}

View file

@ -1,47 +0,0 @@
verbose: false
instrumentation:
root: .
extensions:
- .js
- .jsx
default-excludes: true
excludes: []
variable: __coverage__
compact: true
preserve-comments: false
complete-copy: false
save-baseline: false
baseline-file: ./coverage/coverage-baseline.raw.json
include-all-sources: false
include-pid: false
es-modules: false
auto-wrap: false
reporting:
print: summary
reports:
- html
dir: ./coverage
summarizer: pkg
report-config: {}
watermarks:
statements: [50, 80]
functions: [50, 80]
branches: [50, 80]
lines: [50, 80]
hooks:
hook-run-in-context: false
post-require-hook: null
handle-sigint: false
check:
global:
statements: 100
lines: 100
branches: 100
functions: 100
excludes: []
each:
statements: 100
lines: 100
branches: 100
functions: 100
excludes: []

4
node_modules/is-callable/.nycrc generated vendored
View file

@ -2,10 +2,6 @@
"all": true,
"check-coverage": false,
"reporter": ["text-summary", "text", "html", "json"],
"lines": 86,
"statements": 85.93,
"functions": 82.43,
"branches": 76.06,
"exclude": [
"coverage",
"test"

View file

@ -1,3 +1,67 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.2.7](https://github.com/inspect-js/is-callable/compare/v1.2.6...v1.2.7) - 2022-09-23
### Commits
- [Fix] recognize `document.all` in IE 6-10 [`06c1db2`](https://github.com/inspect-js/is-callable/commit/06c1db2b9b2e0f28428e1293eb572f8f93871ec7)
- [Tests] improve logic for FF 20-35 [`0f7d9b9`](https://github.com/inspect-js/is-callable/commit/0f7d9b9c7fe149ca87e71f0a125ade251a6a578c)
- [Fix] handle `document.all` in FF 27 (and +, probably) [`696c661`](https://github.com/inspect-js/is-callable/commit/696c661b8c0810c2d05ab172f1607f4e77ddf81e)
- [Tests] fix proxy tests in FF 42-63 [`985df0d`](https://github.com/inspect-js/is-callable/commit/985df0dd36f8cfe6f1993657b7c0f4cfc19dae30)
- [readme] update tested browsers [`389e919`](https://github.com/inspect-js/is-callable/commit/389e919493b1cb2010126b0411e5291bf76169bd)
- [Fix] detect `document.all` in Opera 12.16 [`b9f1022`](https://github.com/inspect-js/is-callable/commit/b9f1022b3d7e466b7f09080bd64c253caf644325)
- [Fix] HTML elements: properly report as callable in Opera 12.16 [`17391fe`](https://github.com/inspect-js/is-callable/commit/17391fe02b895777c4337be28dca3b364b743b34)
- [Tests] fix inverted logic in FF3 test [`056ebd4`](https://github.com/inspect-js/is-callable/commit/056ebd48790f46ca18ff5b12f51b44c08ccc3595)
## [v1.2.6](https://github.com/inspect-js/is-callable/compare/v1.2.5...v1.2.6) - 2022-09-14
### Commits
- [Fix] work for `document.all` in Firefox 3 and IE 6-8 [`015132a`](https://github.com/inspect-js/is-callable/commit/015132aaef886ec777b5b3593ef4ce461dd0c7d4)
- [Test] skip function toString check for nullish values [`8698116`](https://github.com/inspect-js/is-callable/commit/8698116f95eb59df8b48ec8e4585fc1cdd8cae9f)
- [readme] add "supported engines" section [`0442207`](https://github.com/inspect-js/is-callable/commit/0442207a89a1554d41ba36daf21862ef7ccbd500)
- [Tests] skip one of the fixture objects in FF 3.6 [`a501141`](https://github.com/inspect-js/is-callable/commit/a5011410bc6edb276c6ec8b47ce5c5d83c4bee15)
- [Tests] allow `class` constructor tests to fail in FF v45 - v54, which has undetectable classes [`b12e4a4`](https://github.com/inspect-js/is-callable/commit/b12e4a4d8c438678bd7710f9f896680150766b51)
- [Fix] Safari 4: regexes should not be considered callable [`4b732ff`](https://github.com/inspect-js/is-callable/commit/4b732ffa34346db3f0193ea4e46b7d4e637e6c82)
- [Fix] properly recognize `document.all` in Safari 4 [`3193735`](https://github.com/inspect-js/is-callable/commit/319373525dc4603346661641840cd9a3e0613136)
## [v1.2.5](https://github.com/inspect-js/is-callable/compare/v1.2.4...v1.2.5) - 2022-09-11
### Commits
- [actions] reuse common workflows [`5bb4b32`](https://github.com/inspect-js/is-callable/commit/5bb4b32dc93987328ab4f396601f751c4a7abd62)
- [meta] better `eccheck` command [`b9bd597`](https://github.com/inspect-js/is-callable/commit/b9bd597322b6e3a24c74c09881ca73e1d9f9f485)
- [meta] use `npmignore` to autogenerate an npmignore file [`3192d38`](https://github.com/inspect-js/is-callable/commit/3192d38527c7fc461d05d5aa93d47628e658bc45)
- [Fix] for HTML constructors, always use `tryFunctionObject` even in pre-toStringTag browsers [`3076ea2`](https://github.com/inspect-js/is-callable/commit/3076ea21d1f6ecc1cb711dcf1da08f257892c72b)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `available-typed-arrays`, `object-inspect`, `safe-publish-latest`, `tape` [`8986746`](https://github.com/inspect-js/is-callable/commit/89867464c42adc5cd375ee074a4574b0295442cb)
- [meta] add `auto-changelog` [`7dda9d0`](https://github.com/inspect-js/is-callable/commit/7dda9d04e670a69ae566c8fa596da4ff4371e615)
- [Fix] properly report `document.all` [`da90b2b`](https://github.com/inspect-js/is-callable/commit/da90b2b68dc4f33702c2e01ad07b4f89bcb60984)
- [actions] update codecov uploader [`c8f847c`](https://github.com/inspect-js/is-callable/commit/c8f847c90e04e54ff73c7cfae86e96e94990e324)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape` [`899ae00`](https://github.com/inspect-js/is-callable/commit/899ae00b6abd10d81fc8bc7f02b345fd885d5f56)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `es-value-fixtures`, `object-inspect`, `tape` [`344e913`](https://github.com/inspect-js/is-callable/commit/344e913b149609bf741aa7345fa32dc0b90d8893)
- [meta] remove greenkeeper config [`737dce5`](https://github.com/inspect-js/is-callable/commit/737dce5590b1abb16183a63cb9d7d26920b3b394)
- [meta] npmignore coverage output [`680a883`](https://github.com/inspect-js/is-callable/commit/680a8839071bf36a419fe66e1ced7a3303c27b28)
<!-- auto-changelog-above -->
1.2.4 / 2021-08-05
=================
* [Fix] use `has-tostringtag` approach to behave correctly in the presence of symbol shams
* [readme] fix repo URLs
* [readme] add actions and codecov badges
* [readme] remove defunct badges
* [meta] ignore eclint checking coverage output
* [meta] use `prepublishOnly` script for npm 7+
* [actions] use `node/install` instead of `node/run`; use `codecov` action
* [actions] remove unused workflow file
* [Tests] run `nyc` on all tests; use `tape` runner
* [Tests] use `available-typed-arrays`, `for-each`, `has-symbols`, `object-inspect`
* [Dev Deps] update `available-typed-arrays`, `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `tape`
1.2.3 / 2021-01-31
=================
* [Fix] `document.all` is callable (do not use `document.all`!)

45
node_modules/is-callable/README.md generated vendored
View file

@ -1,6 +1,7 @@
# is-callable <sup>[![Version Badge][2]][1]</sup>
[![Build Status][3]][4]
[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
@ -8,10 +9,24 @@
[![npm badge][11]][1]
[![browser support][9]][10]
Is this JS value callable? Works with Functions and GeneratorFunctions, despite ES6 @@toStringTag.
## Supported engines
Automatically tested in every minor version of node.
Manually tested in:
- Safari: v4 - v15 <sub>(4, 5, 5.1, 6.0.5, 6.2, 7.1, 8, 9.1.3, 10.1.2, 11.1.2, 12.1, 13.1.2, 14.1.2, 15.3, 15.6.1)</sub>
- Note: Safari 9 has `class`, but `Function.prototype.toString` hides that progeny and makes them look like functions, so `class` constructors will be reported by this package as callable, when they are not in fact callable.
- Chrome: v15 - v81, v83 - v106<sub>(every integer version)</sub>
- Note: This includes Edge v80+ and Opera v15+, which matches Chrome
- Firefox: v3, v3.6, v4 - v105 <sub>(every integer version)</sub>
- Note: v45 - v54 has `class`, but `Function.prototype.toString` hides that progeny and makes them look like functions, so `class` constructors will be reported by this package as callable, when they are not in fact callable.
- Note: in v42 - v63, `Function.prototype.toString` throws on HTML element constructors, or a Proxy to a function
- Note: in v20 - v35, HTML element constructors are not callable, despite having typeof `function`.
- Note: in v19, `document.all` is not callable.
- IE: v6 - v11<sub>(every integer version</sub>
- Opera: v11.1, v11.5, v11.6, v12.1, v12.14, v12.15, v12.16, v15+ <sub>v15+ matches Chrome</sub>
## Example
```js
@ -52,17 +67,17 @@ npm install is-callable
Simply clone the repo, `npm install`, and run `npm test`
[1]: https://npmjs.org/package/is-callable
[2]: http://versionbadg.es/ljharb/is-callable.svg
[3]: https://travis-ci.org/ljharb/is-callable.svg
[4]: https://travis-ci.org/ljharb/is-callable
[5]: https://david-dm.org/ljharb/is-callable.svg
[6]: https://david-dm.org/ljharb/is-callable
[7]: https://david-dm.org/ljharb/is-callable/dev-status.svg
[8]: https://david-dm.org/ljharb/is-callable#info=devDependencies
[9]: https://ci.testling.com/ljharb/is-callable.png
[10]: https://ci.testling.com/ljharb/is-callable
[2]: https://versionbadg.es/inspect-js/is-callable.svg
[5]: https://david-dm.org/inspect-js/is-callable.svg
[6]: https://david-dm.org/inspect-js/is-callable
[7]: https://david-dm.org/inspect-js/is-callable/dev-status.svg
[8]: https://david-dm.org/inspect-js/is-callable#info=devDependencies
[11]: https://nodei.co/npm/is-callable.png?downloads=true&stars=true
[license-image]: http://img.shields.io/npm/l/is-callable.svg
[license-image]: https://img.shields.io/npm/l/is-callable.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/is-callable.svg
[downloads-url]: http://npm-stat.com/charts.html?package=is-callable
[downloads-image]: https://img.shields.io/npm/dm/is-callable.svg
[downloads-url]: https://npm-stat.com/charts.html?package=is-callable
[codecov-image]: https://codecov.io/gh/inspect-js/is-callable/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/inspect-js/is-callable/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-callable
[actions-url]: https://github.com/inspect-js/is-callable/actions

45
node_modules/is-callable/index.js generated vendored
View file

@ -43,32 +43,59 @@ var tryFunctionObject = function tryFunctionToStr(value) {
}
};
var toStr = Object.prototype.toString;
var objectClass = '[object Object]';
var fnClass = '[object Function]';
var genClass = '[object GeneratorFunction]';
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
/* globals document: false */
var documentDotAll = typeof document === 'object' && typeof document.all === 'undefined' && document.all !== undefined ? document.all : {};
var ddaClass = '[object HTMLAllCollection]'; // IE 11
var ddaClass2 = '[object HTML document.all class]';
var ddaClass3 = '[object HTMLCollection]'; // IE 9-10
var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag`
var isIE68 = !(0 in [,]); // eslint-disable-line no-sparse-arrays, comma-spacing
var isDDA = function isDocumentDotAll() { return false; };
if (typeof document === 'object') {
// Firefox 3 canonicalizes DDA to undefined when it's not accessed directly
var all = document.all;
if (toStr.call(all) === toStr.call(document.all)) {
isDDA = function isDocumentDotAll(value) {
/* globals document: false */
// in IE 6-8, typeof document.all is "object" and it's truthy
if ((isIE68 || !value) && (typeof value === 'undefined' || typeof value === 'object')) {
try {
var str = toStr.call(value);
return (
str === ddaClass
|| str === ddaClass2
|| str === ddaClass3 // opera 12.16
|| str === objectClass // IE 6-8
) && value('') == null; // eslint-disable-line eqeqeq
} catch (e) { /**/ }
}
return false;
};
}
}
module.exports = reflectApply
? function isCallable(value) {
if (value === documentDotAll) { return true; }
if (isDDA(value)) { return true; }
if (!value) { return false; }
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
if (typeof value === 'function' && !value.prototype) { return true; }
try {
reflectApply(value, null, badArrayLike);
} catch (e) {
if (e !== isCallableMarker) { return false; }
}
return !isES6ClassFn(value);
return !isES6ClassFn(value) && tryFunctionObject(value);
}
: function isCallable(value) {
if (value === documentDotAll) { return true; }
if (isDDA(value)) { return true; }
if (!value) { return false; }
if (typeof value !== 'function' && typeof value !== 'object') { return false; }
if (typeof value === 'function' && !value.prototype) { return true; }
if (hasToStringTag) { return tryFunctionObject(value); }
if (isES6ClassFn(value)) { return false; }
var strClass = toStr.call(value);
return strClass === fnClass || strClass === genClass;
if (strClass !== fnClass && strClass !== genClass && !(/^\[object HTML/).test(strClass)) { return false; }
return tryFunctionObject(value);
};

View file

@ -1,6 +1,6 @@
{
"name": "is-callable",
"version": "1.2.3",
"version": "1.2.7",
"author": {
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
@ -20,27 +20,21 @@
"license": "MIT",
"main": "index.js",
"scripts": {
"prepublish": "safe-publish-latest",
"prepack": "npmignore --auto --commentLines=autogenerated",
"version": "auto-changelog && git add CHANGELOG.md",
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\"",
"prepublishOnly": "safe-publish-latest",
"prepublish": "not-in-publish || npm run prepublishOnly",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"posttest": "npx aud --production",
"tests-only": "npm run --silent test:stock && npm run --silent test:staging",
"test:stock": "node test",
"test:staging": "node --es-staging test",
"coverage": "npm run --silent istanbul",
"covert": "covert test",
"covert:quiet": "covert test --quiet",
"istanbul": "npm run --silent istanbul:clean && npm run --silent istanbul:std && npm run --silent istanbul:harmony && npm run --silent istanbul:merge && istanbul check",
"istanbul:clean": "rimraf coverage coverage-std coverage-harmony",
"istanbul:merge": "istanbul-merge --out coverage/coverage.raw.json coverage-harmony/coverage.raw.json coverage-std/coverage.raw.json && istanbul report html",
"istanbul:harmony": "node --harmony ./node_modules/istanbul/lib/cli.js cover test --dir coverage-harmony",
"istanbul:std": "istanbul cover test --report html --dir coverage-std",
"prelint": "eclint check *",
"lint": "eslint ."
"test": "npm run tests-only --",
"posttest": "aud --production",
"tests-only": "nyc tape 'test/**/*.js'",
"prelint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git')",
"lint": "eslint --ext=js,mjs ."
},
"repository": {
"type": "git",
"url": "git://github.com/ljharb/is-callable.git"
"url": "git://github.com/inspect-js/is-callable.git"
},
"keywords": [
"Function",
@ -54,22 +48,25 @@
"toStringTag",
"@@toStringTag"
],
"dependencies": {},
"devDependencies": {
"@ljharb/eslint-config": "^17.5.0",
"aud": "^1.1.3",
"covert": "^1.1.1",
"@ljharb/eslint-config": "^21.0.0",
"aud": "^2.0.0",
"auto-changelog": "^2.4.0",
"available-typed-arrays": "^1.0.5",
"eclint": "^2.8.1",
"eslint": "^7.19.0",
"foreach": "^2.0.5",
"istanbul": "1.1.0-alpha.1",
"istanbul-merge": "^1.1.1",
"es-value-fixtures": "^1.4.2",
"eslint": "=8.8.0",
"for-each": "^0.3.3",
"has-tostringtag": "^1.0.0",
"make-arrow-function": "^1.2.0",
"make-async-function": "^1.0.0",
"make-generator-function": "^2.0.0",
"npmignore": "^0.3.0",
"nyc": "^10.3.2",
"object-inspect": "^1.12.2",
"rimraf": "^2.7.1",
"safe-publish-latest": "^1.1.4",
"tape": "^5.1.1"
"safe-publish-latest": "^2.0.0",
"tape": "^5.6.0"
},
"testling": {
"files": "test/index.js",
@ -92,9 +89,18 @@
"engines": {
"node": ">= 0.4"
},
"greenkeeper": {
"auto-changelog": {
"output": "CHANGELOG.md",
"template": "keepachangelog",
"unreleased": false,
"commitLimit": false,
"backfillLimit": false,
"hideCredit": true,
"startingVersion": "v1.2.5"
},
"publishConfig": {
"ignore": [
"rimraf"
".github/workflows"
]
}
}

View file

@ -1,11 +1,14 @@
'use strict';
/* globals Proxy */
/* eslint no-magic-numbers: 1 */
var test = require('tape');
var isCallable = require('../');
var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
var hasToStringTag = require('has-tostringtag/shams')();
var v = require('es-value-fixtures');
var forEach = require('for-each');
var inspect = require('object-inspect');
var typedArrayNames = require('available-typed-arrays')();
var generators = require('make-generator-function')();
var arrows = require('make-arrow-function').list();
var asyncs = require('make-async-function').list();
@ -15,7 +18,16 @@ try {
weirdlyCommentedArrowFn = Function('return cl/*/**/=>/**/ass - 1;')();
/* eslint-enable no-new-func */
} catch (e) { /**/ }
var forEach = require('foreach');
var isIE68 = !(0 in [undefined]);
var isFirefox = typeof window !== 'undefined' && ('netscape' in window) && (/ rv:/).test(navigator.userAgent);
var fnToStringCoerces;
try {
Function.prototype.toString.call(v.uncoercibleFnObject);
fnToStringCoerces = true;
} catch (e) {
fnToStringCoerces = false;
}
var noop = function () {};
var classFake = function classFake() { }; // eslint-disable-line func-name-matching
@ -36,11 +48,8 @@ if (typeof Proxy === 'function') {
proxy();
String(proxy);
} catch (_) {
// If `Reflect` is supported, then `Function.prototype.toString` isn't used for callability detection.
if (typeof Reflect !== 'object') {
// Older engines throw a `TypeError` when `Function.prototype.toString` is called on a Proxy object.
proxy = null;
}
// Older engines throw a `TypeError` when `Function.prototype.toString` is called on a Proxy object.
proxy = null;
}
}
@ -56,6 +65,7 @@ var invokeFunction = function invokeFunctionString(str) {
};
var classConstructor = invokeFunction('"use strict"; return class Foo {}');
var hasDetectableClasses = classConstructor && Function.prototype.toString.call(classConstructor) === 'class Foo {}';
var commentedClass = invokeFunction('"use strict"; return class/*kkk*/\n//blah\n Bar\n//blah\n {}');
var commentedClassOneLine = invokeFunction('"use strict"; return class/**/A{}');
@ -63,46 +73,51 @@ var classAnonymous = invokeFunction('"use strict"; return class{}');
var classAnonymousCommentedOneLine = invokeFunction('"use strict"; return class/*/*/{}');
test('not callables', function (t) {
t.test('non-number/string primitives', function (st) {
st.notOk(isCallable(), 'undefined is not callable');
st.notOk(isCallable(null), 'null is not callable');
st.notOk(isCallable(false), 'false is not callable');
st.notOk(isCallable(true), 'true is not callable');
st.end();
});
t.notOk(isCallable(), 'implicit undefined is not callable');
t.notOk(isCallable([]), 'array is not callable');
t.notOk(isCallable({}), 'object is not callable');
t.notOk(isCallable(/a/g), 'regex literal is not callable');
t.notOk(isCallable(new RegExp('a', 'g')), 'regex object is not callable');
t.notOk(isCallable(new Date()), 'new Date() is not callable');
t.test('numbers', function (st) {
st.notOk(isCallable(42), 'number is not callable');
st.notOk(isCallable(Object(42)), 'number object is not callable');
st.notOk(isCallable(NaN), 'NaN is not callable');
st.notOk(isCallable(Infinity), 'Infinity is not callable');
st.end();
});
t.test('strings', function (st) {
st.notOk(isCallable('foo'), 'string primitive is not callable');
st.notOk(isCallable(Object('foo')), 'string object is not callable');
st.end();
forEach(v.nonFunctions.concat([
Object(42),
Object('foo'),
NaN,
[],
/a/g,
new RegExp('a', 'g'),
new Date()
]), function (nonFunction) {
if (fnToStringCoerces && nonFunction === v.coercibleFnObject) {
t.comment('FF 3.6 has a Function toString that coerces its receiver, so this test is skipped');
return;
}
if (nonFunction != null) { // eslint-disable-line eqeqeq
if (isFirefox) {
// Firefox 3 throws some kind of *object* here instead of a proper error
t['throws'](
function () { Function.prototype.toString.call(nonFunction); },
inspect(nonFunction) + ' can not be used with Function toString'
);
} else {
t['throws'](
function () { Function.prototype.toString.call(nonFunction); },
TypeError,
inspect(nonFunction) + ' can not be used with Function toString'
);
}
}
t.equal(isCallable(nonFunction), false, inspect(nonFunction) + ' is not callable');
});
t.test('non-function with function in its [[Prototype]] chain', function (st) {
var Foo = function Bar() {};
Foo.prototype = noop;
st.equal(true, isCallable(Foo), 'sanity check: Foo is callable');
st.equal(false, isCallable(new Foo()), 'instance of Foo is not callable');
st.equal(isCallable(Foo), true, 'sanity check: Foo is callable');
st.equal(isCallable(new Foo()), false, 'instance of Foo is not callable');
st.end();
});
t.end();
});
test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t) {
test('@@toStringTag', { skip: !hasToStringTag }, function (t) {
var fakeFunction = {
toString: function () { return String(return3); },
valueOf: return3
@ -114,18 +129,6 @@ test('@@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (t)
t.end();
});
var typedArrayNames = [
'Int8Array',
'Uint8Array',
'Uint8ClampedArray',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array'
];
test('Functions', function (t) {
t.ok(isCallable(noop), 'function is callable');
t.ok(isCallable(classFake), 'function with name containing "class" is callable');
@ -134,14 +137,9 @@ test('Functions', function (t) {
t.end();
});
test('Typed Arrays', function (st) {
test('Typed Arrays', { skip: typedArrayNames.length === 0 }, function (st) {
forEach(typedArrayNames, function (typedArray) {
/* istanbul ignore if : covered in node 0.6 */
if (typeof global[typedArray] === 'undefined') {
st.comment('# SKIP typed array "' + typedArray + '" not supported');
} else {
st.ok(isCallable(global[typedArray]), typedArray + ' is callable');
}
st.ok(isCallable(global[typedArray]), typedArray + ' is callable');
});
st.end();
});
@ -161,7 +159,12 @@ test('Arrow functions', { skip: arrows.length === 0 }, function (t) {
t.end();
});
test('"Class" constructors', { skip: !classConstructor || !commentedClass || !commentedClassOneLine || !classAnonymous }, function (t) {
test('"Class" constructors', {
skip: !classConstructor || !commentedClass || !commentedClassOneLine || !classAnonymous, todo: !hasDetectableClasses
}, function (t) {
if (!hasDetectableClasses) {
t.comment('WARNING: This engine does not support detectable classes');
}
t.notOk(isCallable(classConstructor), 'class constructors are not callable');
t.notOk(isCallable(commentedClass), 'class constructors with comments in the signature are not callable');
t.notOk(isCallable(commentedClassOneLine), 'one-line class constructors with comments in the signature are not callable');
@ -178,7 +181,7 @@ test('`async function`s', { skip: asyncs.length === 0 }, function (t) {
});
test('proxies of functions', { skip: !proxy }, function (t) {
t.ok(isCallable(proxy), 'proxies of functions are callable');
t.equal(isCallable(proxy), true, 'proxies of functions are callable');
t.end();
});
@ -189,10 +192,53 @@ test('throwing functions', function (t) {
t.ok(isCallable(thrower), 'a function that throws is callable');
});
/* globals document: false */
test('document.all', { skip: typeof document !== 'object' }, function (t) {
t.notOk(isCallable(document), 'document is not callable');
t.ok(isCallable(document.all), 'document.all is callable');
test('DOM', function (t) {
/* eslint-env browser */
t.test('document.all', { skip: typeof document !== 'object' }, function (st) {
st.notOk(isCallable(document), 'document is not callable');
var all = document.all;
var isFF3 = !isIE68 && Object.prototype.toString(all) === Object.prototype.toString.call(document.all); // this test is true in IE 6-8 also
var expected = false;
if (!isFF3) {
try {
expected = document.all('') == null; // eslint-disable-line eqeqeq
} catch (e) { /**/ }
}
st.equal(isCallable(document.all), expected, 'document.all is ' + (isFF3 ? 'not ' : '') + 'callable');
st.end();
});
forEach([
'HTMLElement',
'HTMLAnchorElement'
], function (name) {
var constructor = global[name];
t.test(name, { skip: !constructor }, function (st) {
st.match(typeof constructor, /^(?:function|object)$/, name + ' is a function or object');
var callable = isCallable(constructor);
st.equal(typeof callable, 'boolean');
if (callable) {
st.doesNotThrow(
function () { Function.prototype.toString.call(constructor); },
'anything this library claims is callable should be accepted by Function toString'
);
} else {
st['throws'](
function () { Function.prototype.toString.call(constructor); },
TypeError,
'anything this library claims is not callable should not be accepted by Function toString'
);
}
st.end();
});
});
t.end();
});