diff --git a/package-lock.json b/package-lock.json index b993176f..0c438a8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -409,6 +409,12 @@ "integrity": "sha512-+0i2xcYryUoLawi47Lp0iJKzkP931G5GXwIOq1KBKQc2pknV1VPjfE6b4mI2mR2RnL7WRoS30YjwC9SjQgJDXQ==", "dev": true }, + "eslint-plugin-rulesdir": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-rulesdir/-/eslint-plugin-rulesdir-0.1.0.tgz", + "integrity": "sha1-rRRNfphGT9qClj7/P6szGuyyvwg=", + "dev": true + }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", diff --git a/package.json b/package.json index 47658553..48fc9c89 100644 --- a/package.json +++ b/package.json @@ -1,42 +1,43 @@ { - "name": "eslint-plugin-no-jquery", - "version": "2.2.1", - "description": "Disallow jQuery functions with native equivalents.", - "repository": { - "type": "git", - "url": "git+https://github.com/wikimedia/eslint-plugin-no-jquery.git" - }, - "license": "MIT", - "keywords": [ - "eslint", - "eslintplugin", - "eslint-plugin" - ], - "main": "index.js", - "scripts": { - "pretest": "eslint .", - "test": "mocha --reporter dot tests/", - "testpath": "mocha", - "doc": "rm docs/* && mocha --reporter min tests/ --doc" - }, - "files": [ - "index.js", - "rules/*" - ], - "peerDependencies": { - "eslint": ">=2.3.0" - }, - "devDependencies": { - "eslint": "^6.4.0", - "eslint-config-wikimedia": "^0.14.3", - "mocha": "^6.2.0" - }, - "bugs": { - "url": "https://github.com/wikimedia/eslint-plugin-no-jquery/issues" - }, - "homepage": "https://github.com/wikimedia/eslint-plugin-no-jquery#readme", - "directories": { - "test": "tests" - }, - "dependencies": {} + "name": "eslint-plugin-no-jquery", + "version": "2.2.1", + "description": "Disallow jQuery functions with native equivalents.", + "repository": { + "type": "git", + "url": "git+https://github.com/wikimedia/eslint-plugin-no-jquery.git" + }, + "license": "MIT", + "keywords": [ + "eslint", + "eslintplugin", + "eslint-plugin" + ], + "main": "index.js", + "scripts": { + "pretest": "eslint --report-unused-disable-directives .", + "test": "mocha --reporter dot tests/", + "testpath": "mocha", + "doc": "rm docs/* && mocha --reporter min tests/ --doc" + }, + "files": [ + "index.js", + "rules/*" + ], + "peerDependencies": { + "eslint": ">=2.3.0" + }, + "devDependencies": { + "eslint": "^6.4.0", + "eslint-config-wikimedia": "^0.14.3", + "eslint-plugin-rulesdir": "^0.1.0", + "mocha": "^6.2.0" + }, + "bugs": { + "url": "https://github.com/wikimedia/eslint-plugin-no-jquery/issues" + }, + "homepage": "https://github.com/wikimedia/eslint-plugin-no-jquery#readme", + "directories": { + "test": "tests" + }, + "dependencies": {} } diff --git a/test-all/.eslintrc.js b/test-all/.eslintrc.js new file mode 100644 index 00000000..8c1c12af --- /dev/null +++ b/test-all/.eslintrc.js @@ -0,0 +1,21 @@ +const rulesDirPlugin = require( 'eslint-plugin-rulesdir' ); +const rules = require( '../index.js' ).rules; + +// Relative to root +rulesDirPlugin.RULES_DIR = './rules'; + +const conf = { + "plugins": [ + "rulesdir" + ], + "globals": { + "$": "readonly" + }, + "rules": {} +}; + +for ( let rule in rules ) { + conf.rules[ 'rulesdir/' + rule ] = 'error'; +} + +module.exports = conf; diff --git a/test-all/methods.js b/test-all/methods.js new file mode 100644 index 00000000..6417da3c --- /dev/null +++ b/test-all/methods.js @@ -0,0 +1,227 @@ +/** + * This file lists all known methods, for tracking #112 + * + * Once a rule has been created for a method, it should be disabled + * with a "next-line" directive, and moved to the bottom half of + * the file. + * + * The rule prefix is renamed from no-jquery to rulesdir as the + * rules are loaded directly via the rulesdir plugin. + */ +var $x; +$x.add(); +$x.addBack(); +$x.after(); +$x.append(); +$x.appendTo(); +$x.before(); +$x.children(); +$x.clearQueue(); +$x.constructor(); +$x.contents(); +$x.delay(); +$x.dequeue(); +$x.detach(); +$x.empty(); +$x.end(); +$x.eq(); +$x.extend(); +$x.finish(); +$x.first(); +$x.get(); +$x.height(); +$x.index(); +$x.init(); +$x.innerHeight(); +$x.innerWidth(); +$x.insertAfter(); +$x.insertBefore(); +$x.last(); +$x.next(); +$x.nextAll(); +$x.nextUntil(); +$x.not(); +$x.off(); +$x.offset(); +$x.offsetParent(); +$x.on(); +$x.one(); +$x.outerHeight(); +$x.outerWidth(); +$x.parentsUntil(); +$x.parse(); +$x.position(); +$x.prepend(); +$x.prependTo(); +$x.prev(); +$x.prevAll(); +$x.prevUntil(); +$x.promise(); +$x.pushStack(); +$x.queue(); +$x.remove(); +$x.replaceAll(); +$x.replaceWith(); +$x.scrollLeft(); +$x.scrollTop(); +$x.siblings(); +$x.slice(); +$x.stop(); +$x.toArray(); +$x.triggerHandler(); +$x.width(); + +// eslint-disable-next-line rulesdir/no-class +$x.addClass(); +// eslint-disable-next-line rulesdir/no-event-shorthand, rulesdir/no-ajax-events +$x.ajaxComplete(); +// eslint-disable-next-line rulesdir/no-event-shorthand, rulesdir/no-ajax-events +$x.ajaxError(); +// eslint-disable-next-line rulesdir/no-event-shorthand, rulesdir/no-ajax-events +$x.ajaxSend(); +// eslint-disable-next-line rulesdir/no-event-shorthand, rulesdir/no-ajax-events +$x.ajaxStart(); +// eslint-disable-next-line rulesdir/no-event-shorthand, rulesdir/no-ajax-events +$x.ajaxStop(); +// eslint-disable-next-line rulesdir/no-event-shorthand, rulesdir/no-ajax-events +$x.ajaxSuccess(); +// eslint-disable-next-line rulesdir/no-animate +$x.animate(); +// eslint-disable-next-line rulesdir/no-attr +$x.attr(); +// eslint-disable-next-line rulesdir/no-bind +$x.bind(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.blur(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.change(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.click(); +// eslint-disable-next-line rulesdir/no-clone +$x.clone(); +// eslint-disable-next-line rulesdir/no-closest +$x.closest(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.contextmenu(); +// eslint-disable-next-line rulesdir/no-css +$x.css(); +// eslint-disable-next-line rulesdir/no-data +$x.data(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.dblclick(); +// eslint-disable-next-line rulesdir/no-delegate +$x.delegate(); +// eslint-disable-next-line rulesdir/no-each, rulesdir/no-each-collection +$x.each(); +// eslint-disable-next-line rulesdir/no-fade +$x.fadeIn(); +// eslint-disable-next-line rulesdir/no-fade +$x.fadeOut(); +// eslint-disable-next-line rulesdir/no-fade +$x.fadeTo(); +// eslint-disable-next-line rulesdir/no-fade +$x.fadeToggle(); +// eslint-disable-next-line rulesdir/no-filter +$x.filter(); +// eslint-disable-next-line rulesdir/no-find +$x.find(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.focus(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.focusin(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.focusout(); +// eslint-disable-next-line rulesdir/no-has +$x.has(); +// eslint-disable-next-line rulesdir/no-class, rulesdir/no-class-state +$x.hasClass(); +// eslint-disable-next-line rulesdir/no-hide +$x.hide(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.hover(); +// eslint-disable-next-line rulesdir/no-html +$x.html(); +// eslint-disable-next-line rulesdir/no-is +$x.is(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.keydown(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.keypress(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.keyup(); +// eslint-disable-next-line rulesdir/no-load, rulesdir/no-event-shorthand, rulesdir/no-load-shorthand +$x.load(); +// eslint-disable-next-line rulesdir/no-map, rulesdir/no-map-collection +$x.map(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.mousedown(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.mouseenter(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.mouseleave(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.mousemove(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.mouseout(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.mouseover(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.mouseup(); +// eslint-disable-next-line rulesdir/no-parent +$x.parent(); +// eslint-disable-next-line rulesdir/no-parents +$x.parents(); +// eslint-disable-next-line rulesdir/no-prop +$x.prop(); +// eslint-disable-next-line rulesdir/no-ready, rulesdir/no-ready-shorthand +$x.ready(); +// eslint-disable-next-line rulesdir/no-attr +$x.removeAttr(); +// eslint-disable-next-line rulesdir/no-class +$x.removeClass(); +// eslint-disable-next-line rulesdir/no-data +$x.removeData(); +// eslint-disable-next-line rulesdir/no-prop +$x.removeProp(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.resize(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.scroll(); +// eslint-disable-next-line rulesdir/no-event-shorthand +$x.select(); +// eslint-disable-next-line rulesdir/no-serialize +$x.serialize(); +// eslint-disable-next-line rulesdir/no-serialize +$x.serializeArray(); +// eslint-disable-next-line rulesdir/no-show +$x.show(); +// eslint-disable-next-line rulesdir/no-slide +$x.slideDown(); +// eslint-disable-next-line rulesdir/no-slide +$x.slideToggle(); +// eslint-disable-next-line rulesdir/no-slide +$x.slideUp(); +// eslint-disable-next-line rulesdir/no-event-shorthand, rulesdir/no-submit +$x.submit(); +// eslint-disable-next-line rulesdir/no-text +$x.text(); +// eslint-disable-next-line rulesdir/no-toggle +$x.toggle(); +// eslint-disable-next-line rulesdir/no-class +$x.toggleClass(); +// eslint-disable-next-line rulesdir/no-trigger +$x.trigger(); +// eslint-disable-next-line rulesdir/no-unbind +$x.unbind(); +// eslint-disable-next-line rulesdir/no-undelegate +$x.undelegate(); +// eslint-disable-next-line rulesdir/no-wrap +$x.unwrap(); +// eslint-disable-next-line rulesdir/no-val +$x.val(); +// eslint-disable-next-line rulesdir/no-wrap +$x.wrap(); +// eslint-disable-next-line rulesdir/no-wrap +$x.wrapAll(); +// eslint-disable-next-line rulesdir/no-wrap +$x.wrapInner(); diff --git a/test-all/utils.js b/test-all/utils.js new file mode 100644 index 00000000..46ed1e50 --- /dev/null +++ b/test-all/utils.js @@ -0,0 +1,130 @@ +/** + * This file lists all known methods, for tracking #112 + * + * Once a rule has been created for a method, it should be disabled + * with a "next-line" directive, and moved to the bottom half of + * the file. + * + * The rule prefix is renamed from no-jquery to rulesdir as the + * rules are loaded directly via the rulesdir plugin. + */ + +/* eslint-disable no-underscore-dangle */ +$._data(); +$._evalUrl(); +$._queueHooks(); +$._removeData(); +$.ajaxPrefilter(); +$.ajaxSetup(); +$.ajaxTransport(); +$.Animation(); +$.Callbacks(); +$.cleanData(); +$.dequeue(); +$.escapeSelector(); +$.Event(); +$.fx(); +$.htmlPrefilter(); +$.isXMLDoc(); +$.makeArray(); +$.noConflict(); +$.parseXML(); +$.queue(); +$.ready(); +$.readyException(); +$.removeEvent(); +$.speed(); +$.style(); +$.Tween(); +$.uniqueSort(); + +// eslint-disable-next-line rulesdir/no-ajax +$.ajax(); +// eslint-disable-next-line rulesdir/no-attr +$.attr(); +// eslint-disable-next-line rulesdir/no-camel-case +$.camelCase(); +// eslint-disable-next-line rulesdir/no-clone +$.clone(); +// eslint-disable-next-line rulesdir/no-contains +$.contains(); +// eslint-disable-next-line rulesdir/no-css +$.css(); +// eslint-disable-next-line rulesdir/no-data +$.data(); +// eslint-disable-next-line rulesdir/no-deferred +$.Deferred(); +// eslint-disable-next-line rulesdir/no-each, rulesdir/no-each-util +$.each(); +// eslint-disable-next-line rulesdir/no-error +$.error(); +// eslint-disable-next-line rulesdir/no-extend +$.extend(); +// eslint-disable-next-line rulesdir/no-filter +$.filter(); +// eslint-disable-next-line rulesdir/no-find +$.find(); +// eslint-disable-next-line rulesdir/no-ajax +$.get(); +// eslint-disable-next-line rulesdir/no-ajax +$.getJSON(); +// eslint-disable-next-line rulesdir/no-ajax +$.getScript(); +// eslint-disable-next-line rulesdir/no-global-eval +$.globalEval(); +// eslint-disable-next-line rulesdir/no-grep +$.grep(); +// eslint-disable-next-line rulesdir/no-data +$.hasData(); +// eslint-disable-next-line rulesdir/no-hold-ready +$.holdReady(); +// eslint-disable-next-line rulesdir/no-in-array +$.inArray(); +// eslint-disable-next-line rulesdir/no-is-array +$.isArray(); +// eslint-disable-next-line rulesdir/no-is-empty-object +$.isEmptyObject(); +// eslint-disable-next-line rulesdir/no-is-function +$.isFunction(); +// eslint-disable-next-line rulesdir/no-is-numeric +$.isNumeric(); +// eslint-disable-next-line rulesdir/no-is-plain-object +$.isPlainObject(); +// eslint-disable-next-line rulesdir/no-is-window +$.isWindow(); +// eslint-disable-next-line rulesdir/no-map, rulesdir/no-map-util +$.map(); +// eslint-disable-next-line rulesdir/no-merge +$.merge(); +// eslint-disable-next-line rulesdir/no-node-name +$.nodeName(); +// eslint-disable-next-line rulesdir/no-noop +$.noop(); +// eslint-disable-next-line rulesdir/no-now +$.now(); +// eslint-disable-next-line rulesdir/no-param +$.param(); +// eslint-disable-next-line rulesdir/no-parse-html +$.parseHTML(); +// eslint-disable-next-line rulesdir/no-parse-json +$.parseJSON(); +// eslint-disable-next-line rulesdir/no-ajax +$.post(); +// eslint-disable-next-line rulesdir/no-prop +$.prop(); +// eslint-disable-next-line rulesdir/no-proxy +$.proxy(); +// eslint-disable-next-line rulesdir/no-attr +$.removeAttr(); +// eslint-disable-next-line rulesdir/no-data +$.removeData(); +// eslint-disable-next-line rulesdir/no-text +$.text(); +// eslint-disable-next-line rulesdir/no-trim +$.trim(); +// eslint-disable-next-line rulesdir/no-type +$.type(); +// eslint-disable-next-line rulesdir/no-unique +$.unique(); +// eslint-disable-next-line rulesdir/no-when +$.when();