@es-shims/api
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -12,3 +12,6 @@ { | ||
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], | ||
"requireCurlyBraces": { | ||
"allExcept": [], | ||
"keywords": ["if", "else", "for", "while", "do", "try", "catch"] | ||
}, | ||
@@ -20,2 +23,3 @@ "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], | ||
"disallowSpaceBeforeComma": true, | ||
"disallowSpaceAfterComma": false, | ||
"disallowSpaceBeforeSemicolon": true, | ||
@@ -32,3 +36,3 @@ | ||
"requireObjectKeysOnNewLine": true, | ||
"requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, | ||
@@ -82,3 +86,3 @@ "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, | ||
"requireDotNotation": true, | ||
"requireDotNotation": { "allExcept": ["keywords"] }, | ||
@@ -126,4 +130,35 @@ "requireParenthesesAroundIIFE": true, | ||
"validateOrderInObjectKeys": "asc-insensitive" | ||
"disallowMultiLineTernary": true, | ||
"validateOrderInObjectKeys": "asc-insensitive", | ||
"disallowIdenticalDestructuringNames": true, | ||
"disallowNestedTernaries": { "maxLevel": 1 }, | ||
"requireSpaceAfterComma": { "allExcept": ["trailing"] }, | ||
"requireAlignedMultilineParams": false, | ||
"requireSpacesInGenerator": { | ||
"afterStar": true | ||
}, | ||
"disallowSpacesInGenerator": { | ||
"beforeStar": true | ||
}, | ||
"disallowVar": false, | ||
"requireArrayDestructuring": false, | ||
"requireEnhancedObjectLiterals": false, | ||
"requireObjectDestructuring": false, | ||
"requireEarlyReturn": false, | ||
"requireCapitalizedConstructorsNew": { | ||
"allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] | ||
} | ||
} | ||
33
api.js
@@ -8,2 +8,3 @@ #!/usr/bin/env node | ||
var fs = require('fs'); | ||
var existsSync = path.existsSync || fs.existsSync; | ||
@@ -16,9 +17,10 @@ var args = process.argv.slice(2); // remove node, and script name | ||
var isBound = args.some(argEqualsBound); | ||
var moduleNames = args.filter(not(argEqualsBound)).map(function (name) { | ||
return [name, name]; | ||
}); | ||
var makeEntries = function (name) { return [name, name]; }; | ||
var moduleNames = args | ||
.filter(not(argEqualsBound)) | ||
.map(makeEntries); | ||
if (moduleNames.length < 1) { | ||
var packagePath = path.join(process.cwd(), 'package.json'); | ||
if (!fs.existsSync(packagePath)) { | ||
if (!existsSync(packagePath)) { | ||
console.error('Error: No package.json found in the current directory'); | ||
@@ -33,3 +35,3 @@ console.error('at least one module name is required when not run in a directory with a package.json'); | ||
} | ||
moduleNames.push([pkg.name + ' (current directory)', process.cwd()]); | ||
moduleNames.push([pkg.name + ' (current directory)', [path.join(process.cwd(), pkg.main || ''), process.cwd()]]); | ||
} | ||
@@ -43,12 +45,19 @@ var requireOrEvalError = function (name) { | ||
}; | ||
var validateModule = function validateModule(t, name) { | ||
var validateModule = function validateModule(t, nameOrFilePaths) { | ||
var name = nameOrFilePaths; | ||
var packageDir = nameOrFilePaths; | ||
if (Array.isArray(nameOrFilePaths)) { | ||
name = nameOrFilePaths[0]; | ||
packageDir = nameOrFilePaths[1]; | ||
} | ||
var module = requireOrEvalError(name); | ||
var implementation = requireOrEvalError(name + '/implementation'); | ||
var shim = requireOrEvalError(name + '/shim'); | ||
var getPolyfill = requireOrEvalError(name + '/polyfill'); | ||
if (module instanceof EvalError) { return module; } | ||
var implementation = requireOrEvalError(packageDir + '/implementation'); | ||
var shim = requireOrEvalError(packageDir + '/shim'); | ||
var getPolyfill = requireOrEvalError(packageDir + '/polyfill'); | ||
t.test('export', function (st) { | ||
st.equal(typeof module, 'function', 'module is a function'); | ||
st.test('module is NOT bound (pass `--bound` to skip this test', { skip: isBound }, function (st2) { | ||
st2.equal(module, implementation, 'module.exports === implementation.js'); | ||
st.test('module is NOT bound (pass `--bound` to skip this test)', { skip: isBound }, function (st2) { | ||
st2.equal(module, getPolyfill(), 'module.exports === getPolyfill()'); | ||
st2.end(); | ||
@@ -85,5 +94,5 @@ }); | ||
t.comment('* ----------------------------- * #'); | ||
validateModule(t, filePath); | ||
t.error(validateModule(t, filePath), 'expected no error'); | ||
t.end(); | ||
}); | ||
}); |
@@ -0,3 +1,13 @@ | ||
1.1.0 / 2016-02-06 | ||
================== | ||
* [New] Require that the default export be `getPolyfill()` instead of `implementation` | ||
* [Fix] Handle the case where `package.json`'s "main" entry point is not `index.js` | ||
* [Fix] Make sure `existsSync` works in node 0.6 and below | ||
* [Deps] update `tape` | ||
* [Dev Deps] update `jscs`, `eslint`, `@ljharb/eslint-config`, `nsp`, `semver` | ||
* [Tests] up to `node` `v5.5` | ||
* [Tests] fix npm upgrades for older nodes | ||
1.0.0 / 2015-08-15 | ||
================== | ||
* Initial release. |
{ | ||
"name": "@es-shims/api", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"author": "Jordan Harband", | ||
@@ -15,3 +15,3 @@ "description": "Loosely test a package's compliance with the es-shim API", | ||
"eslint": "eslint *.js", | ||
"security": "nsp package" | ||
"security": "nsp check" | ||
}, | ||
@@ -36,12 +36,12 @@ "repository": { | ||
"dependencies": { | ||
"tape": "^4.2.0" | ||
"tape": "^4.4.0" | ||
}, | ||
"devDependencies": { | ||
"jscs": "^2.1.0", | ||
"nsp": "^1.0.3", | ||
"eslint": "^1.1.0", | ||
"@ljharb/eslint-config": "^1.0.4", | ||
"make-arrow-function": "^1.0.0", | ||
"jscs": "^2.9.0", | ||
"nsp": "^2.2.0", | ||
"eslint": "^1.10.3", | ||
"@ljharb/eslint-config": "^1.6.1", | ||
"make-arrow-function": "^1.1.0", | ||
"make-generator-function": "^1.1.0", | ||
"semver": "^5.0.1", | ||
"semver": "^5.1.0", | ||
"replace": "^0.3.0" | ||
@@ -48,0 +48,0 @@ }, |
@@ -11,11 +11,9 @@ # es-shim API <sup>[![Version Badge][2]][1]</sup> | ||
[![browser support][9]][10] | ||
## API Contract | ||
For any given “es-shim API”-compliant package `foo`, the following invariants must hold: | ||
- This package will run in an environment supporting the oldest JS version in which the spec’s semantics are achievable - ES3, ES5, and/or ES6. The package should indicate its minimum level of required environment support in its README. | ||
- The package must attempt to support `node`/`io.js`, all versions of all ES3-compliant browers or later, Web Workers, and `node-webkit`. Other environments are a plus, but not expected. | ||
- `require('foo')` is a spec-compliant JS function. However, if the function’s behavior depends on a receiver (a “this” value), then the first argument to this function will be used as that receiver. The package should indicate if this is the case in its README. | ||
- The package must attempt to support `node`/`io.js`, all versions of all ES3-compliant browsers or later, Web Workers, and `node-webkit`. Other environments are a plus, but not expected. | ||
- `require('foo')` is a spec-compliant JS or native function. However, if the function’s behavior depends on a receiver (a “this” value), then the first argument to this function will be used as that receiver. The package should indicate if this is the case in its README. | ||
- `require('foo').implementation` or `require('foo/implementation')` is a spec-compliant JS function, that will depend on a receiver (a “this” value) as the spec requires. | ||
- `require('foo').getPolyfill` or `require('foo/polyfill')` is a function that when invoked, will return the most compliant and performant function that it can - if a native version is available, and does not violate the spec, then the native function will be returned - otherwise, either the `implementation`, or a custom, wrapped version of the native function, will be returned. | ||
- `require('foo').getPolyfill` or `require('foo/polyfill')` is a function that when invoked, will return the most compliant and performant function that it can - if a native version is available, and does not violate the spec, then the native function will be returned - otherwise, either the `implementation`, or a custom, wrapped version of the native function, will be returned. This is also the result that will be used as the default export. | ||
- `require('foo').shim` or `require('foo/shim')` is a function that when invoked, will call `getPolyfill`, and if the polyfill doesn’t match the built-in value, will install it into the global environment. | ||
@@ -37,3 +35,3 @@ - The only place the package may modify the environment is within its `shim` method. | ||
```md | ||
This package implements the [es-shim API](https://github/com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](http://www.ecma-international.org/ecma-262/6.0/). | ||
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](http://www.ecma-international.org/ecma-262/6.0/). | ||
``` | ||
@@ -61,8 +59,6 @@ Please modify “ES3” as needed to the level of support, and please update the spec link so it points directly to the most relevant section of the spec it complies with. | ||
[4]: https://travis-ci.org/es-shims/es-shim-api | ||
[5]: https://david-dm.org/es-shims/api.svg | ||
[6]: https://david-dm.org/es-shims/api | ||
[7]: https://david-dm.org/es-shims/api/dev-status.svg | ||
[8]: https://david-dm.org/es-shims/api#info=devDependencies | ||
[9]: https://ci.testling.com/es-shims/api.png | ||
[10]: https://ci.testling.com/es-shims/api | ||
[5]: https://david-dm.org/es-shims/es-shim-api.svg | ||
[6]: https://david-dm.org/es-shims/es-shim-api | ||
[7]: https://david-dm.org/es-shims/es-shim-api/dev-status.svg | ||
[8]: https://david-dm.org/es-shims/es-shim-api#info=devDependencies | ||
[11]: https://nodei.co/npm/@es-shims/api.png?downloads=true&stars=true | ||
@@ -69,0 +65,0 @@ [license-image]: http://img.shields.io/npm/l/@es-shims/api.svg |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23204
11
187
69
1
Updatedtape@^4.4.0