Skip to content

Commit

Permalink
Check for multi-spaces with eslint, fix those and cleanup some DOCs a…
Browse files Browse the repository at this point in the history
…nd notes
  • Loading branch information
rejas committed Apr 18, 2019
1 parent 5afbd12 commit 6a2f425
Show file tree
Hide file tree
Showing 25 changed files with 70 additions and 77 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Expand Up @@ -26,6 +26,7 @@
"no-cond-assign": ["error", "except-parens"],
"no-eq-null": "error",
"no-eval": "error",
"no-multi-spaces": ["error", { "ignoreEOLComments": true }],
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
"no-undef": "error",
"no-unused-expressions": "error",
Expand Down
26 changes: 13 additions & 13 deletions feature-detects/audio.js
Expand Up @@ -2,7 +2,11 @@
{
"name": "HTML5 Audio Element",
"property": "audio",
"tags": ["html5", "audio", "media"]
"tags": ["html5", "audio", "media"],
"notes": [{
"name": "MDN Docs",
"href": "https://developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements"
}]
}
!*/
/* DOC
Expand All @@ -29,18 +33,14 @@ define(['Modernizr', 'createElement'], function(Modernizr, createElement) {
try {
bool = !!elem.canPlayType;
if (bool) {
bool = new Boolean(bool);
bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"') .replace(/^no$/, '');
bool.mp3 = elem.canPlayType('audio/mpeg; codecs="mp3"') .replace(/^no$/, '');
bool.opus = elem.canPlayType('audio/ogg; codecs="opus"') ||
elem.canPlayType('audio/webm; codecs="opus"') .replace(/^no$/, '');

// Mimetypes accepted:
// developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
// bit.ly/iphoneoscodecs
bool.wav = elem.canPlayType('audio/wav; codecs="1"') .replace(/^no$/, '');
bool.m4a = (elem.canPlayType('audio/x-m4a;') ||
elem.canPlayType('audio/aac;')) .replace(/^no$/, '');
bool = new Boolean(bool);
bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '');
bool.mp3 = elem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '');
bool.opus = elem.canPlayType('audio/ogg; codecs="opus"') ||
elem.canPlayType('audio/webm; codecs="opus"').replace(/^no$/, '');
bool.wav = elem.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '');
bool.m4a = (elem.canPlayType('audio/x-m4a;') ||
elem.canPlayType('audio/aac;')).replace(/^no$/, '');
}
} catch (e) {}

Expand Down
4 changes: 2 additions & 2 deletions feature-detects/canvastext.js
Expand Up @@ -11,8 +11,8 @@
Detects support for the text APIs for `<canvas>` elements.
*/
define(['Modernizr', 'createElement', 'test/canvas'], function(Modernizr, createElement) {
Modernizr.addTest('canvastext', function() {
if (Modernizr.canvas === false) {
Modernizr.addTest('canvastext', function() {
if (Modernizr.canvas === false) {
return false;
}
return typeof createElement('canvas').getContext('2d').fillText === 'function';
Expand Down
16 changes: 8 additions & 8 deletions feature-detects/css/backgroundcliptext.js
Expand Up @@ -5,14 +5,14 @@
"authors": ["ausi"],
"tags": ["css"],
"notes": [{
"name": "CSS Tricks Article",
"href": "https://css-tricks.com/image-under-text/"
},{
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip"
},{
"name": "Related Github Issue",
"href": "https://github.com/Modernizr/Modernizr/issues/199"
"name": "CSS Tricks Article",
"href": "https://css-tricks.com/image-under-text/"
},{
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip"
},{
"name": "Related Github Issue",
"href": "https://github.com/Modernizr/Modernizr/issues/199"
}]
}
!*/
Expand Down
22 changes: 11 additions & 11 deletions feature-detects/css/pointerevents.js
Expand Up @@ -7,17 +7,17 @@
"tags": ["css"],
"builderAliases": ["css_pointerevents"],
"notes": [{
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events"
},{
"name": "Test Project Page",
"href": "https://ausi.github.com/Feature-detection-technique-for-pointer-events/"
},{
"name": "Test Project Wiki",
"href": "https://github.com/ausi/Feature-detection-technique-for-pointer-events/wiki"
},{
"name": "Related Github Issue",
"href": "https://github.com/Modernizr/Modernizr/issues/80"
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events"
},{
"name": "Test Project Page",
"href": "https://ausi.github.com/Feature-detection-technique-for-pointer-events/"
},{
"name": "Test Project Wiki",
"href": "https://github.com/ausi/Feature-detection-technique-for-pointer-events/wiki"
},{
"name": "Related Github Issue",
"href": "https://github.com/Modernizr/Modernizr/issues/80"
}]
}
!*/
Expand Down
2 changes: 1 addition & 1 deletion feature-detects/css/pseudotransitions.js
Expand Up @@ -5,7 +5,7 @@
"tags": ["css"]
}
!*/
define(['Modernizr', 'testStyles', 'prefixes', 'test/css/transitions'], function(Modernizr, testStyles, prefixes) {
define(['Modernizr', 'testStyles', 'prefixes', 'test/css/transitions'], function(Modernizr, testStyles, prefixes) {
Modernizr.addTest('csspseudotransitions', function() {
var result = false;

Expand Down
8 changes: 4 additions & 4 deletions feature-detects/css/textalignlast.js
Expand Up @@ -5,11 +5,11 @@
"tags": ["css"],
"knownBugs": ["IE does not support the 'start' or 'end' values."],
"notes": [{
"name": "Quirksmode",
"href": "https://www.quirksmode.org/css/text/textalignlast.html"
"name": "Quirksmode",
"href": "https://www.quirksmode.org/css/text/textalignlast.html"
},{
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/CSS/text-align-last"
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/CSS/text-align-last"
}]
}
!*/
Expand Down
2 changes: 0 additions & 2 deletions feature-detects/customevent.js
Expand Up @@ -15,9 +15,7 @@
}
!*/
/* DOC
Detects support for CustomEvent.
*/
define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('customevent', 'CustomEvent' in window && typeof window.CustomEvent === 'function');
Expand Down
2 changes: 0 additions & 2 deletions feature-detects/dom/mutationObserver.js
Expand Up @@ -13,9 +13,7 @@
}
!*/
/* DOC
Determines if DOM4 MutationObserver support is available.
*/
define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('mutationobserver',
Expand Down
4 changes: 2 additions & 2 deletions feature-detects/elem/ruby.js
Expand Up @@ -27,10 +27,10 @@ define(['Modernizr', 'createElement', 'docElement'], function(Modernizr, createE
docElement.appendChild(ruby);

// browsers that support <ruby> hide the <rp> via "display:none"
if (getStyle(rp, displayStyleProperty) === 'none' || // for non-IE browsers
if (getStyle(rp, displayStyleProperty) === 'none' || // for non-IE browsers
// but in IE browsers <rp> has "display:inline" so, the test needs other conditions:
getStyle(ruby, displayStyleProperty) === 'ruby' && getStyle(rt, displayStyleProperty) === 'ruby-text' || // for IE8+
getStyle(rp, fontSizeStyleProperty) === '6pt' && getStyle(rt, fontSizeStyleProperty) === '6pt') { // for IE6 & IE7
getStyle(rp, fontSizeStyleProperty) === '6pt' && getStyle(rt, fontSizeStyleProperty) === '6pt') { // for IE6 & IE7

cleanUp();
return true;
Expand Down
2 changes: 1 addition & 1 deletion feature-detects/event/oninput.js
Expand Up @@ -35,7 +35,7 @@ define(['Modernizr', 'docElement', 'createElement', 'testStyles', 'hasEvent'], f
// their trident equivalent.
try {
// Older Firefox didn't map oninput attribute to oninput property
var testEvent = document.createEvent('KeyboardEvent');
var testEvent = document.createEvent('KeyboardEvent');
supportsOnInput = false;
var handler = function(e) {
supportsOnInput = true;
Expand Down
2 changes: 1 addition & 1 deletion feature-detects/forms/validation.js
Expand Up @@ -26,7 +26,7 @@ define(['Modernizr', 'createElement', 'docElement', 'testStyles'], function(Mode
var invalidFired = false;
var input;

Modernizr.formvalidationapi = true;
Modernizr.formvalidationapi = true;

// Prevent form from being submitted
form.addEventListener('submit', function(e) {
Expand Down
2 changes: 1 addition & 1 deletion feature-detects/img/sizes.js
Expand Up @@ -25,7 +25,7 @@ define(['Modernizr', 'createElement', 'addTest'], function(Modernizr, createElem
var isSizes = 'sizes' in image;

// ... but we need to deal with Safari 9...
if (!isSizes && ('srcset' in image)) {
if (!isSizes && ('srcset' in image)) {
width2 = 'data:image/gif;base64,R0lGODlhAgABAPAAAP///wAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==';
width1 = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';

Expand Down
2 changes: 1 addition & 1 deletion feature-detects/inputsearchevent.js
Expand Up @@ -17,5 +17,5 @@
There is a custom `search` event implemented in webkit browsers when using an `input[search]` element.
*/
define(['Modernizr', 'hasEvent'], function(Modernizr, hasEvent) {
Modernizr.addTest('inputsearchevent', hasEvent('search'));
Modernizr.addTest('inputsearchevent', hasEvent('search'));
});
4 changes: 2 additions & 2 deletions feature-detects/inputtypes.js
Expand Up @@ -67,7 +67,7 @@ define(['Modernizr', 'inputElem', 'docElement'], function(Modernizr, inputElem,
// If the value doesn't stick, we know there's input sanitization which infers a custom UI
if (bool) {

inputElem.value = smile;
inputElem.value = smile;
inputElem.style.cssText = 'position:absolute;visibility:hidden;';

if (/^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined) {
Expand All @@ -76,7 +76,7 @@ define(['Modernizr', 'inputElem', 'docElement'], function(Modernizr, inputElem,
defaultView = document.defaultView;

// Safari 2-4 allows the smiley as a value, despite making a slider
bool = defaultView.getComputedStyle &&
bool = defaultView.getComputedStyle &&
defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
// Mobile android web browser has false positive, so must
// check the height to see if the widget is actually there.
Expand Down
8 changes: 4 additions & 4 deletions feature-detects/intl.js
Expand Up @@ -3,11 +3,11 @@
"name": "Internationalization API",
"property": "intl",
"notes": [{
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl"
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl"
},{
"name": "ECMAScript spec",
"href": "https://www.ecma-international.org/ecma-402/1.0/"
"name": "ECMAScript spec",
"href": "https://www.ecma-international.org/ecma-402/1.0/"
}]
}
!*/
Expand Down
2 changes: 0 additions & 2 deletions feature-detects/window/atob-btoa.js
Expand Up @@ -17,9 +17,7 @@
}
!*/
/* DOC
Detects support for WindowBase64 API (window.atob && window.btoa).
*/
define(['Modernizr'], function(Modernizr) {
Modernizr.addTest('atobbtoa', 'atob' in window && 'btoa' in window, {aliases: ['atob-btoa']});
Expand Down
2 changes: 0 additions & 2 deletions feature-detects/window/matchmedia.js
Expand Up @@ -16,9 +16,7 @@
}
!*/
/* DOC
Detects support for matchMedia.
*/
define(['Modernizr', 'prefixed'], function(Modernizr, prefixed) {
Modernizr.addTest('matchmedia', !!prefixed('matchMedia', window));
Expand Down
6 changes: 3 additions & 3 deletions feature-detects/workers/blobworkers.js
Expand Up @@ -22,12 +22,12 @@ define(['Modernizr', 'addTest'], function(Modernizr, addTest) {
// we're avoiding using Modernizr._domPrefixes as the prefix capitalization on
// these guys are notoriously peculiar.
var BlobBuilder = window.BlobBuilder;
var URL = window.URL;
var URL = window.URL;
if (Modernizr._config.usePrefix) {
BlobBuilder = BlobBuilder || window.MozBlobBuilder || window.WebKitBlobBuilder || window.MSBlobBuilder || window.OBlobBuilder;
URL = URL || window.MozURL || window.webkitURL || window.MSURL || window.OURL;
URL = URL || window.MozURL || window.webkitURL || window.MSURL || window.OURL;
}
var data = 'Modernizr',
var data = 'Modernizr',
blob,
bb,
worker,
Expand Down
4 changes: 2 additions & 2 deletions feature-detects/workers/dataworkers.js
Expand Up @@ -19,8 +19,8 @@ Detects support for creating Web Workers from Data URIs.
define(['Modernizr', 'addTest'], function(Modernizr, addTest) {
Modernizr.addAsyncTest(function() {
try {
var data = 'Modernizr',
worker = new Worker('data:text/javascript;base64,dGhpcy5vbm1lc3NhZ2U9ZnVuY3Rpb24oZSl7cG9zdE1lc3NhZ2UoZS5kYXRhKX0=');
var data = 'Modernizr',
worker = new Worker('data:text/javascript;base64,dGhpcy5vbm1lc3NhZ2U9ZnVuY3Rpb24oZSl7cG9zdE1lc3NhZ2UoZS5kYXRhKX0=');

worker.onmessage = function(e) {
worker.terminate();
Expand Down
2 changes: 1 addition & 1 deletion lib/generate-banner.js
Expand Up @@ -15,7 +15,7 @@ define(['lodash', 'package', 'lib/build-query'], function(_, pkg, buildQuery) {
config = config || {};
var query = buildQuery(config);
if (!type || type === 'compact') {
return '/*! ' + pkg.name + ' ' + pkg.version + ' (Custom Build) | ' + pkg.license + ' *\n' +
return '/*! ' + pkg.name + ' ' + pkg.version + ' (Custom Build) | ' + pkg.license + ' *\n' +
' * https://' + domain + '/download/' + query +
' !*/\n';
}
Expand Down
2 changes: 1 addition & 1 deletion test/browser/integration/caniuse.js
Expand Up @@ -330,7 +330,7 @@ window.caniusecb = function(caniuse) {

var majorminor = ua.browser.version
// opera gets grouped in some cases by caniuse
.replace(/(9\.(6|5))/ , ua.browser.name === 'Opera' ? '9.5-9.6' : '$1')
.replace(/(9\.(6|5))/ , ua.browser.name === 'Opera' ? '9.5-9.6' : '$1')
.replace(/(10\.(0|1))/, ua.browser.name === 'Opera' ? '10.0-10.1' : '$1');

// make sure the version keys of the caniusedata is sorted as numbers not as strings
Expand Down
12 changes: 6 additions & 6 deletions test/browser/integration/prefixed.js
Expand Up @@ -5,8 +5,8 @@ describe('prefixed()', function() {
function gimmePrefix(prop, obj) {
var prefixes = ['Khtml', 'Webkit', 'ms', 'O', 'Moz'],
domPrefixes = ['khtml', 'webkit', 'ms', 'o', 'moz'],
elem = document.createElement('div'),
upper = prop.charAt(0).toUpperCase() + prop.slice(1),
elem = document.createElement('div'),
upper = prop.charAt(0).toUpperCase() + prop.slice(1),
len;

if (!obj) {
Expand All @@ -15,7 +15,7 @@ describe('prefixed()', function() {
}

for (len = prefixes.length; len--;) {
if ((prefixes[len] + upper) in elem.style) {
if ((prefixes[len] + upper) in elem.style) {
return (prefixes[len] + upper);
}
}
Expand Down Expand Up @@ -44,9 +44,9 @@ describe('prefixed()', function() {
'borderRadius', 'boxShadow', 'columnCount'];

var domPropArr = [
{'prop': 'requestAnimationFrame', 'obj': window},
{'prop': 'querySelectorAll', 'obj': document},
{'prop': 'matchesSelector', 'obj': document.createElement('div')}];
{'prop': 'requestAnimationFrame', 'obj': window},
{'prop': 'querySelectorAll', 'obj': document},
{'prop': 'matchesSelector', 'obj': document.createElement('div')}];

_.forEach(propArr, function(prop) {
it('results for ' + prop + ' match the homebaked prefix finder', function() {
Expand Down
8 changes: 4 additions & 4 deletions test/browser/integration/prefixedCSS.js
Expand Up @@ -2,8 +2,8 @@ describe('prefixedCSS', function() {
function gimmePrefix(prop, obj) {
var prefixes = ['Moz', 'Khtml', 'Webkit', 'O', 'ms'],
domPrefixes = ['moz', 'khtml', 'webkit', 'o', 'ms'],
elem = document.createElement('div'),
upper = prop.charAt(0).toUpperCase() + prop.slice(1),
elem = document.createElement('div'),
upper = prop.charAt(0).toUpperCase() + prop.slice(1),
len;

if (!obj) {
Expand All @@ -12,7 +12,7 @@ describe('prefixedCSS', function() {
}

for (len = prefixes.length; len--;) {
if ((prefixes[len] + upper) in elem.style) {
if ((prefixes[len] + upper) in elem.style) {
return (prefixes[len] + upper);
}
}
Expand All @@ -22,7 +22,7 @@ describe('prefixedCSS', function() {
}

for (len = domPrefixes.length; len--;) {
if ((domPrefixes[len] + upper) in obj) {
if ((domPrefixes[len] + upper) in obj) {
return (domPrefixes[len] + upper);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/universal/lib/generate-banner.js
Expand Up @@ -50,7 +50,7 @@ describe('generate-banner', function() {

it('should produce a compact banner when requested', function() {
var banner = generateBanner('compact');
var test = '/*! ' + pkg.name + ' ' + pkg.version + ' (Custom Build) | ' + pkg.license + ' *';
var test = '/*! ' + pkg.name + ' ' + pkg.version + ' (Custom Build) | ' + pkg.license + ' *';
expect(banner).to.contain(test);
});

Expand Down

0 comments on commit 6a2f425

Please sign in to comment.