Wrap the /regexp/ literal in parens to disambiguate the slash operator.

New rules

Ideas for new linting rules that we should write.

Name

Severity

Description

object-prototype-external

Warning

Flags calls to methods of Object.prototype that rely on the prototype chain. For example this code should be flagged:

foo.hasOwnProperty("bar")

Example (1) is unsafe, as foo may have a property named hasOwnProperty, or have been constructed via Object.create(null).

As for this:

Object.hasOwnProperty.call(foo,"bar")

Example (2) technically relies on the prototype chain as well: the hasOwnProperty method is defined on Object.prototype, not Object. Object inherits the methods of Object.prototype through its prototype chain. However (2) is unlikely to fail, as sane JavaScript programs will not modify the global objects' prototypes. If we choose to flag (2), it should only be for style.

Rule priority

Here are the rules we want to support, grouped by priority. Implemented rules are struck out.

Critical

block-scoped-var

eqeqeq

no-undef

no-redeclare

no-unused-vars

no-use-before-define

Important

guard-for-in

no-dupe-keys

no-octal

no-with

radix

semi

wrap-iife

Nice to have

dot-notation

new-cap

new-parens

no-caller

no-comma-dangle

no-implied-eval

no-new-array

no-new-object

no-undef-init

no-unused-expressions

no-wrap-func

use-isnan

Tests

Every rule needs extensive unit tests

Unit tests should use Mocha

Unit tests should work when run from Node or the browser (TODO)

User interface

Should we have a UI for configuring what rules are active?

Should we try to support .eslintrc? This would be an ideal project-scope setting.

Should we try to honor equivalent JSLint/JSHint flags when possible? For example /*jslint eqeqeq:false */ could disable the eqeqeq rule on a per-file basis.

This would give compatibility with Orion codebase which uses these flags.

OTOH, eslint now has its own syntax for this: /*eslint ..*/, which we should perhaps use instead.

i18n

We need to support i18n. Pre-req is bug 422278 (orion.edit.validator support for i18n).