jss-plugin-compose
Advanced tools
Comparing version 10.0.0-alpha.3 to 10.0.0-alpha.4
@@ -1,50 +0,19 @@ | ||
/** | ||
* Copyright 2014-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
var warning = function warning() {}; | ||
{ | ||
warning = function warning(condition, format, args) { | ||
var len = arguments.length; | ||
args = new Array(len > 2 ? len - 2 : 0); | ||
for (var key = 2; key < len; key++) { | ||
args[key - 2] = arguments[key]; | ||
function warning(condition, message) { | ||
{ | ||
if (condition) { | ||
return; | ||
} | ||
if (format === undefined) { | ||
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); | ||
} | ||
var text = "Warning: " + message; | ||
if (format.length < 10 || /^[s\W]*$/.test(format)) { | ||
throw new Error('The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format); | ||
if (typeof console !== 'undefined') { | ||
console.warn(text); | ||
} | ||
if (!condition) { | ||
var argIndex = 0; | ||
var message = 'Warning: ' + format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(message); | ||
} | ||
try { | ||
// This error was thrown as a convenience so that you can use this stack | ||
// to find the callsite that caused this warning to fire. | ||
throw new Error(message); | ||
} catch (x) {} | ||
} | ||
}; | ||
try { | ||
throw Error(text); | ||
} catch (x) {} | ||
} | ||
} | ||
var warning_1 = warning; | ||
/** | ||
@@ -82,3 +51,3 @@ * Set selector. | ||
if (!refRule) { | ||
warning_1(false, '[JSS] Referenced rule is not defined. \r\n%s', rule); | ||
warning(false, "[JSS] Referenced rule is not defined. \n" + rule.toString()); | ||
return false; | ||
@@ -88,3 +57,3 @@ } | ||
if (refRule === rule) { | ||
warning_1(false, '[JSS] Cyclic composition detected. \r\n%s', rule); | ||
warning(false, "[JSS] Cyclic composition detected. \n" + rule.toString()); | ||
return false; | ||
@@ -91,0 +60,0 @@ } |
@@ -7,3 +7,3 @@ 'use strict'; | ||
var warning = _interopDefault(require('warning')); | ||
var warning = _interopDefault(require('tiny-warning')); | ||
@@ -42,3 +42,3 @@ /** | ||
if (!refRule) { | ||
warning(false, '[JSS] Referenced rule is not defined. \r\n%s', rule); | ||
warning(false, "[JSS] Referenced rule is not defined. \n" + rule.toString()); | ||
return false; | ||
@@ -48,3 +48,3 @@ } | ||
if (refRule === rule) { | ||
warning(false, '[JSS] Cyclic composition detected. \r\n%s', rule); | ||
warning(false, "[JSS] Cyclic composition detected. \n" + rule.toString()); | ||
return false; | ||
@@ -51,0 +51,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import warning from 'warning'; | ||
import warning from 'tiny-warning'; | ||
@@ -35,3 +35,3 @@ /** | ||
if (!refRule) { | ||
warning(false, '[JSS] Referenced rule is not defined. \r\n%s', rule); | ||
warning(false, "[JSS] Referenced rule is not defined. \n" + rule.toString()); | ||
return false; | ||
@@ -41,3 +41,3 @@ } | ||
if (refRule === rule) { | ||
warning(false, '[JSS] Cyclic composition detected. \r\n%s', rule); | ||
warning(false, "[JSS] Cyclic composition detected. \n" + rule.toString()); | ||
return false; | ||
@@ -44,0 +44,0 @@ } |
@@ -7,51 +7,20 @@ (function (global, factory) { | ||
/** | ||
* Copyright 2014-2015, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
var warning = function warning() {}; | ||
{ | ||
warning = function warning(condition, format, args) { | ||
var len = arguments.length; | ||
args = new Array(len > 2 ? len - 2 : 0); | ||
for (var key = 2; key < len; key++) { | ||
args[key - 2] = arguments[key]; | ||
function warning(condition, message) { | ||
{ | ||
if (condition) { | ||
return; | ||
} | ||
if (format === undefined) { | ||
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); | ||
} | ||
var text = "Warning: " + message; | ||
if (format.length < 10 || /^[s\W]*$/.test(format)) { | ||
throw new Error('The warning format should be able to uniquely identify this ' + 'warning. Please, use a more descriptive format than: ' + format); | ||
if (typeof console !== 'undefined') { | ||
console.warn(text); | ||
} | ||
if (!condition) { | ||
var argIndex = 0; | ||
var message = 'Warning: ' + format.replace(/%s/g, function () { | ||
return args[argIndex++]; | ||
}); | ||
if (typeof console !== 'undefined') { | ||
console.error(message); | ||
} | ||
try { | ||
// This error was thrown as a convenience so that you can use this stack | ||
// to find the callsite that caused this warning to fire. | ||
throw new Error(message); | ||
} catch (x) {} | ||
} | ||
}; | ||
try { | ||
throw Error(text); | ||
} catch (x) {} | ||
} | ||
} | ||
var warning_1 = warning; | ||
/** | ||
@@ -89,3 +58,3 @@ * Set selector. | ||
if (!refRule) { | ||
warning_1(false, '[JSS] Referenced rule is not defined. \r\n%s', rule); | ||
warning(false, "[JSS] Referenced rule is not defined. \n" + rule.toString()); | ||
return false; | ||
@@ -95,3 +64,3 @@ } | ||
if (refRule === rule) { | ||
warning_1(false, '[JSS] Cyclic composition detected. \r\n%s', rule); | ||
warning(false, "[JSS] Cyclic composition detected. \n" + rule.toString()); | ||
return false; | ||
@@ -98,0 +67,0 @@ } |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.jssPluginCompose={})}(this,function(e){"use strict";var i=function(){};e.default=function(){return{onProcessStyle:function(e,n){return"composes"in e&&(function e(n,t){if(!t)return!0;if(Array.isArray(t)){for(var r=0;r<t.length;r++)if(!e(n,t[r]))return!1;return!0}if(-1<t.indexOf(" "))return e(n,t.split(" "));var s=n.options.parent;if("$"===t[0]){var o=s.getRule(t.substr(1));return o?o===n?(i(!1,"[JSS] Cyclic composition detected. \r\n%s",n),!1):(s.classes[n.key]+=" "+s.classes[o.key],!0):(i(!1,"[JSS] Referenced rule is not defined. \r\n%s",n),!1)}return s.classes[n.key]+=" "+t,!0}(n,e.composes),delete e.composes),e}}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.jssPluginCompose={})}(this,function(e){"use strict";e.default=function(){return{onProcessStyle:function(e,t){return"composes"in e&&(function e(t,n){if(!n)return!0;if(Array.isArray(n)){for(var r=0;r<n.length;r++)if(!e(t,n[r]))return!1;return!0}if(-1<n.indexOf(" "))return e(t,n.split(" "));var s=t.options.parent;if("$"===n[0]){var o=s.getRule(n.substr(1));return o?o===t?(t.toString(),!1):(s.classes[t.key]+=" "+s.classes[o.key],!0):(t.toString(),!1)}return s.classes[t.key]+=" "+n,!0}(t,e.composes),delete e.composes),e}}},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "jss-plugin-compose", | ||
"description": "JSS plugin for classes composition", | ||
"version": "10.0.0-alpha.3", | ||
"version": "10.0.0-alpha.4", | ||
"license": "MIT", | ||
@@ -37,15 +37,16 @@ "homepage": "https://cssinjs.org/jss-compose", | ||
"scripts": { | ||
"build": "node ../../scripts/build.js", | ||
"prepare": "node ../../scripts/build.js", | ||
"check-snapshot": "node ../../scripts/match-snapshot.js" | ||
}, | ||
"devDependencies": { | ||
"jss": "^10.0.0-alpha.3" | ||
"jss": "^10.0.0-alpha.4" | ||
}, | ||
"peerDependencies": { | ||
"jss": "^9.0.0" | ||
"jss": "^10.0.0-alpha.3" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.0.0", | ||
"warning": "^3.0.0" | ||
} | ||
"tiny-warning": "^1.0.2" | ||
}, | ||
"gitHead": "4efd47a4af45de9c8784d68f3a239f9a1d29c942" | ||
} |
// @flow | ||
import warning from 'warning' | ||
import warning from 'tiny-warning' | ||
import type {Plugin, StyleSheet} from 'jss' | ||
@@ -38,3 +38,3 @@ | ||
if (!refRule) { | ||
warning(false, '[JSS] Referenced rule is not defined. \r\n%s', rule) | ||
warning(false, `[JSS] Referenced rule is not defined. \n${rule.toString()}`) | ||
return false | ||
@@ -44,3 +44,3 @@ } | ||
if (refRule === rule) { | ||
warning(false, '[JSS] Cyclic composition detected. \r\n%s', rule) | ||
warning(false, `[JSS] Cyclic composition detected. \n${rule.toString()}`) | ||
return false | ||
@@ -47,0 +47,0 @@ } |
@@ -5,2 +5,3 @@ /* eslint-disable no-underscore-dangle */ | ||
import {create} from 'jss' | ||
import sinon from 'sinon' | ||
import compose from '.' | ||
@@ -12,8 +13,6 @@ | ||
let jss | ||
let warning | ||
let spy | ||
beforeEach(() => { | ||
compose.__Rewire__('warning', (condition, message) => { | ||
warning = message | ||
}) | ||
spy = sinon.spy(console, 'warn') | ||
jss = create(settings).use(compose()) | ||
@@ -23,4 +22,3 @@ }) | ||
afterEach(() => { | ||
compose.__ResetDependency__('warning') | ||
warning = undefined | ||
console.warn.restore() | ||
}) | ||
@@ -44,3 +42,3 @@ | ||
afterEach(() => { | ||
expect(warning).to.be(undefined) | ||
expect(spy.callCount).to.be(0) | ||
}) | ||
@@ -75,3 +73,3 @@ | ||
afterEach(() => { | ||
expect(warning).to.be(undefined) | ||
expect(spy.callCount).to.be(0) | ||
}) | ||
@@ -118,3 +116,3 @@ | ||
afterEach(() => { | ||
expect(warning).to.be(undefined) | ||
expect(spy.callCount).to.be(0) | ||
}) | ||
@@ -181,3 +179,3 @@ | ||
afterEach(() => { | ||
expect(warning).to.be(undefined) | ||
expect(spy.callCount).to.be(0) | ||
}) | ||
@@ -231,3 +229,3 @@ | ||
afterEach(() => { | ||
expect(warning).to.be(undefined) | ||
expect(spy.callCount).to.be(0) | ||
}) | ||
@@ -269,3 +267,13 @@ | ||
}) | ||
expect(warning).to.be('[JSS] Cyclic composition detected. \r\n%s') | ||
expect(spy.callCount).to.be(1) | ||
expect( | ||
spy.calledWithExactly( | ||
'Warning: [JSS] Cyclic composition detected. \n' + | ||
'.a-id {\n' + | ||
' composes: $a;\n' + | ||
' color: red;\n' + | ||
'}' | ||
) | ||
).to.be(true) | ||
}) | ||
@@ -280,5 +288,11 @@ | ||
}) | ||
expect(warning).to.be('[JSS] Referenced rule is not defined. \r\n%s') | ||
expect(spy.callCount).to.be(1) | ||
expect( | ||
spy.calledWithExactly( | ||
'Warning: [JSS] Referenced rule is not defined. \n.a-id {\n composes: $b;\n color: red;\n}' | ||
) | ||
).to.be(true) | ||
}) | ||
}) | ||
}) |
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
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 3 instances in 1 package
0
100
24551
579
+ Addedtiny-warning@^1.0.2
+ Addedcsstype@3.1.3(transitive)
+ Addedjss@10.10.0(transitive)
+ Addedtiny-warning@1.0.3(transitive)
- Removedwarning@^3.0.0
- Removedjs-tokens@4.0.0(transitive)
- Removedjss@9.8.7(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedsymbol-observable@1.2.0(transitive)
- Removedwarning@3.0.0(transitive)