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-redeclare

no-undef

no-use-before-define

Important

guard-for-in

no-dupe-keys

no-octal

no-unused-vars

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

We don't have legal approval to commit the ESLint tests, because I didn't include them in the CQ. Moreover, they are written using vows, whereas Orion is converging on Mocha.

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.

i18n

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