mirror of https://github.com/zulip/zulip.git
lint: Remove old jslint linter.
Now that we're using eslint, jslint is no longer required.
This commit is contained in:
parent
2c940b93ab
commit
1fb9220354
|
@ -1,4 +1,3 @@
|
|||
static/js/bundle.js
|
||||
static/js/blueslip.js
|
||||
puppet/zulip_ops/files/statsd/local.js
|
||||
tools/jslint/check-all.js
|
||||
|
|
|
@ -218,10 +218,6 @@ Files: tools/inject-messages/othello
|
|||
Copyright: Shakespeare
|
||||
License: public-domain
|
||||
|
||||
Files: tools/jslint/jslint.js
|
||||
Copyright: 2002 Douglas Crockford
|
||||
License: XXX-good-not-evil
|
||||
|
||||
Files: tools/review
|
||||
Copyright: 2010 Ksplice, Inc.
|
||||
License: Apache-2.0
|
||||
|
|
|
@ -23,12 +23,7 @@ The Vagrant setup process runs this for you.
|
|||
|
||||
`lint-all` runs many lint checks in parallel, including
|
||||
|
||||
- JavaScript ([JSLint](http://www.jslint.com/))
|
||||
|
||||
> `tools/jslint/check-all.js` contains a pretty fine-grained set of
|
||||
> JSLint options, rule exceptions, and allowed global variables. If
|
||||
> you add a new global, you'll need to add it to the list.
|
||||
|
||||
- JavaScript ([ESLint](http://eslint.org/))
|
||||
- Python ([Pyflakes](http://pypi.python.org/pypi/pyflakes))
|
||||
- templates
|
||||
- Puppet configuration
|
||||
|
|
|
@ -17,9 +17,10 @@ prevent common coding errors.
|
|||
We borrow some open source tools for much of our linting, and the links
|
||||
below will direct you to the official documentation for these projects.
|
||||
|
||||
- [jslint](https://github.com/douglascrockford/JSLint)
|
||||
- [eslint](http://eslint.org)
|
||||
- [mypy](http://mypy-lang.org/)
|
||||
- [puppet](https://puppet.com/) (puppet provides its own mechanism for validating manifests)
|
||||
- [puppet](https://puppet.com/) (puppet provides its own mechanism for
|
||||
validating manifests)
|
||||
- [pyflakes](https://pypi.python.org/pypi/pyflakes)
|
||||
|
||||
Zulip also uses some home-grown code to perform tasks like validating
|
||||
|
@ -81,7 +82,7 @@ Most of our lint checks get performed by `./tools/lint-all`. These include the
|
|||
following checks:
|
||||
|
||||
- Check Python code with pyflakes.
|
||||
- Check JavaScript code with jslint.
|
||||
- Check JavaScript code with eslint.
|
||||
- Check Python code for custom Zulip rules.
|
||||
- Check non-Python code for custom Zulip rules.
|
||||
- Check puppet manifests with the puppet validator.
|
||||
|
@ -102,7 +103,7 @@ The rest of this document pertains to the checks that occur in `./tools/lint-all
|
|||
Zulip has a script called `lint-all` that lives in our "tools" directory.
|
||||
It is the workhorse of our linting system, although in some cases it
|
||||
dispatches the heavy lifting to other components such as pyflakes,
|
||||
jslint, and other home grown tools.
|
||||
eslint, and other home grown tools.
|
||||
|
||||
You can find the source code [here](https://github.com/zulip/zulip/blob/master/tools/lint-all).
|
||||
|
||||
|
@ -161,7 +162,7 @@ that we exempt may be deemed not worthwhile to fix.
|
|||
#### JavaScript code
|
||||
|
||||
We check our JavaScript code in a few different ways:
|
||||
- We run jslint.
|
||||
- We run eslint.
|
||||
- We perform custom Zulip regex checks on the code.
|
||||
- We verify that all addClass calls, with a few exceptions, explicitly
|
||||
contain a CSS class.
|
||||
|
|
|
@ -9,9 +9,6 @@
|
|||
The file may still be accessible under other circumstances, so do
|
||||
not put sensitive information here. */
|
||||
|
||||
// It's fine to use console.log etc. in this file.
|
||||
/*jslint devel: true */
|
||||
|
||||
/*
|
||||
print_elapsed_time("foo", foo)
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/*jslint nomen: true */
|
||||
var message_list = (function () {
|
||||
|
||||
var exports = {};
|
||||
|
@ -642,7 +641,6 @@ $(document).on('message_selected.zulip zuliphashchange.zulip mousewheel', functi
|
|||
return exports;
|
||||
|
||||
}());
|
||||
/*jslint nomen: false */
|
||||
if (typeof module !== 'undefined') {
|
||||
module.exports = message_list;
|
||||
}
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
// Global variables, categorized by place of definition.
|
||||
var globals =
|
||||
// Third-party libraries
|
||||
' $ _ jQuery Spinner Handlebars XDate zxcvbn Intl Notification'
|
||||
+ ' LazyLoad Dropbox SockJS marked i18n'
|
||||
|
||||
// Node-based unit tests
|
||||
+ ' module require'
|
||||
|
||||
// Cocoa<-> Javascript bridge
|
||||
+ ' bridge'
|
||||
|
||||
// index.html
|
||||
+ ' page_params'
|
||||
|
||||
// common.js
|
||||
+ ' status_classes password_quality'
|
||||
|
||||
// setup.js
|
||||
+ ' csrf_token'
|
||||
|
||||
// Modules, defined in their respective files.
|
||||
+ ' compose compose_fade rows hotkeys narrow reload search subs pointer'
|
||||
+ ' composebox_typeahead server_events typeahead_helper notifications hashchange'
|
||||
+ ' invite ui viewport util activity timerender message_list MessageListView blueslip unread stream_list'
|
||||
+ ' message_edit tab_bar emoji popovers navigate people settings alert_words_ui message_store'
|
||||
+ ' avatar feature_flags search_suggestion referral stream_color Dict'
|
||||
+ ' Filter summary admin stream_data muting WinChan muting_ui Socket channel gear_menu'
|
||||
+ ' message_flags bot_data loading favicon resize scroll_bar condense floating_recipient_bar'
|
||||
+ ' copy_and_paste click_handlers topic_list pm_list unread_ui components'
|
||||
|
||||
// colorspace.js
|
||||
+ ' colorspace'
|
||||
|
||||
// tutorial.js
|
||||
+ ' tutorial'
|
||||
|
||||
// templates.js
|
||||
+ ' templates'
|
||||
|
||||
// alert_words.js
|
||||
+ ' alert_words'
|
||||
|
||||
// fenced_code.js
|
||||
+ ' fenced_code'
|
||||
|
||||
// echo.js
|
||||
+ ' echo'
|
||||
|
||||
// localstorage.js
|
||||
+ ' localstorage'
|
||||
|
||||
// zulip.js
|
||||
+ ' home_msg_list current_msg_list'
|
||||
;
|
||||
|
||||
|
||||
var options = {
|
||||
vars: true, // Allow multiple 'var' per function
|
||||
sloppy: true, // Don't require "use strict"
|
||||
white: true, // Lenient whitespace rules
|
||||
plusplus: true, // Allow increment/decrement operators
|
||||
regexp: true, // Allow . and [^...] in regular expressions
|
||||
todo: true, // Allow "TODO" comments.
|
||||
newcap: true, // Don't assume that capitalized functions are
|
||||
// constructors (and the converse)
|
||||
nomen: true, // Tolerate underscore at the beginning of a name
|
||||
stupid: true // Allow synchronous methods
|
||||
};
|
||||
|
||||
|
||||
// For each error.raw message, we can return 'true' to ignore
|
||||
// the error.
|
||||
var exceptions = {
|
||||
"Unexpected 'else' after 'return'." : function () {
|
||||
return true;
|
||||
},
|
||||
|
||||
"Don't make functions within a loop." : function () {
|
||||
return true;
|
||||
},
|
||||
|
||||
// We use typeof to test if a variable exists at all.
|
||||
"Unexpected 'typeof'. Use '===' to compare directly with {a}.": function (error) {
|
||||
return error.a === 'undefined';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var JSLINT = require(path.join(__dirname, 'jslint')).JSLINT;
|
||||
|
||||
var cwd = process.cwd();
|
||||
|
||||
var exit_code = 0;
|
||||
var i;
|
||||
|
||||
// Drop 'node' and the script name from args.
|
||||
for (i=0; i<2; i++) {
|
||||
process.argv.shift();
|
||||
}
|
||||
|
||||
process.argv.forEach(function (filepath) {
|
||||
var contents = fs.readFileSync(filepath, 'utf8');
|
||||
var messages = [];
|
||||
|
||||
// We mutate 'options' so be sure to clear everything.
|
||||
if (filepath.indexOf('static/js/') !== -1) {
|
||||
// Frontend browser code
|
||||
options.browser = true;
|
||||
options.node = false;
|
||||
options.predef = globals.split(/\s+/);
|
||||
} else {
|
||||
// Backend code for Node.js
|
||||
options.browser = false;
|
||||
options.node = true;
|
||||
|
||||
if (filepath.indexOf('frontend_tests/') !== -1) {
|
||||
// Include '$' and browser globals because we use them inside
|
||||
// casper.evaluate
|
||||
options.predef = ['casper', '$', 'document', 'window', 'set_global', 'add_dependencies', 'patch_builtin', 'assert', 'current_msg_list'];
|
||||
} else {
|
||||
options.predef = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!JSLINT(contents, options)) {
|
||||
JSLINT.errors.forEach(function (error) {
|
||||
if (error === null) {
|
||||
// JSLint stopping error
|
||||
messages.push(' (JSLint giving up)');
|
||||
return;
|
||||
}
|
||||
|
||||
var exn = exceptions[error.raw];
|
||||
if (exn && exn(error)) {
|
||||
// Ignore this error.
|
||||
return;
|
||||
}
|
||||
|
||||
// NB: this will break on a 10,000 line file
|
||||
var line = (' ' + error.line).slice(-4);
|
||||
|
||||
messages.push(' ' + line + ' ' + error.reason);
|
||||
});
|
||||
|
||||
if (messages.length > 0) {
|
||||
exit_code = 1;
|
||||
|
||||
console.log(path.relative(cwd, filepath));
|
||||
|
||||
// Something very wacky happens if we do
|
||||
// .forEach(console.log) directly.
|
||||
messages.forEach(function (msg) {
|
||||
console.log(msg);
|
||||
});
|
||||
|
||||
console.log('');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
process.exit(exit_code);
|
File diff suppressed because it is too large
Load Diff
|
@ -30,7 +30,6 @@ puppet/apt/.forge-release
|
|||
puppet/apt/README.md
|
||||
static/locale
|
||||
static/third
|
||||
tools/jslint/jslint.js
|
||||
zerver/migrations
|
||||
zproject/dev_settings.py
|
||||
zproject/settings.py
|
||||
|
@ -502,13 +501,6 @@ def run():
|
|||
result = subprocess.call(['tools/check-css'])
|
||||
return result
|
||||
|
||||
@lint
|
||||
def jslint():
|
||||
# type: () -> int
|
||||
result = subprocess.call(['node', 'tools/jslint/check-all.js']
|
||||
+ by_lang['js'])
|
||||
return result
|
||||
|
||||
@lint
|
||||
def eslint():
|
||||
# type: () -> int
|
||||
|
|
|
@ -35,7 +35,6 @@ certs
|
|||
exclude_files = """
|
||||
zilencer/management/commands/test_messages.txt
|
||||
tools/usability_testing/humbug_usability_test_data
|
||||
tools/jslint/jslint.js
|
||||
""".split()
|
||||
|
||||
extensions = dict(
|
||||
|
|
Loading…
Reference in New Issue