Skip to content
Permalink
Browse files

Fix: Use single quotes in context.report messages (fixes #4845)

While working on a different project that consumes the output of ESLint
and some plugins, we noticed that the quote styles emitted by the
no-undef and no-unused-vars rule were different than the quote styles
emitted by some of the rules in our other plugins [0]. This
inconsistency led to a small bug in our project, so I wanted to smooth
things out a bit for future developers.

To make things more consistent, my first inclination was to change the
plugin to match ESLint's no-undef and no-unused-vars quote style, but
upon investigation it seems there was a fair amount of inconsistency in
ESLint rules: some used double quotes, some used single quotes, and
others used backticks. I decided to convert all of these to single
quotes to be more consistent.

There may be others that I have missed, but this commit should get the
bulk of them.

[0]: Galooshi/import-js#85 (comment)
  • Loading branch information...
lencioni committed Jan 1, 2016
1 parent 72a325c commit 58715e98cfa5b96ac55e90a522c6480f6d5f3442
Showing with 967 additions and 967 deletions.
  1. +4 −4 docs/rules/block-scoped-var.md
  2. +4 −4 docs/rules/block-spacing.md
  3. +3 −3 docs/rules/constructor-super.md
  4. +12 −12 docs/rules/key-spacing.md
  5. +4 −4 docs/rules/no-class-assign.md
  6. +3 −3 docs/rules/no-const-assign.md
  7. +3 −3 docs/rules/no-dupe-class-members.md
  8. +1 −1 docs/rules/no-empty-label.md
  9. +1 −1 docs/rules/no-fallthrough.md
  10. +6 −6 docs/rules/no-implicit-coercion.md
  11. +15 −15 docs/rules/no-invalid-this.md
  12. +1 −1 docs/rules/no-negated-in-lhs.md
  13. +3 −3 docs/rules/no-redeclare.md
  14. +2 −2 docs/rules/no-restricted-syntax.md
  15. +4 −4 docs/rules/no-shadow-restricted-names.md
  16. +8 −8 docs/rules/no-shadow.md
  17. +4 −4 docs/rules/no-this-before-super.md
  18. +3 −3 docs/rules/no-undef.md
  19. +3 −3 docs/rules/no-underscore-dangle.md
  20. +4 −4 docs/rules/no-unmodified-loop-condition.md
  21. +7 −7 docs/rules/no-unused-vars.md
  22. +5 −5 docs/rules/no-use-before-define.md
  23. +7 −7 docs/rules/no-useless-call.md
  24. +4 −4 docs/rules/no-warning-comments.md
  25. +3 −3 docs/rules/prefer-const.md
  26. +2 −2 docs/rules/prefer-rest-params.md
  27. +4 −4 docs/rules/prefer-spread.md
  28. +13 −13 docs/rules/quote-props.md
  29. +1 −1 docs/rules/require-yield.md
  30. +4 −4 docs/rules/space-after-keywords.md
  31. +8 −8 docs/rules/space-before-keywords.md
  32. +3 −3 docs/rules/space-return-throw-case.md
  33. +9 −9 docs/rules/space-unary-ops.md
  34. +15 −15 docs/rules/spaced-comment.md
  35. +7 −7 docs/rules/strict.md
  36. +3 −3 docs/rules/vars-on-top.md
  37. +1 −1 lib/rules/block-scoped-var.js
  38. +2 −2 lib/rules/block-spacing.js
  39. +4 −4 lib/rules/constructor-super.js
  40. +2 −2 lib/rules/key-spacing.js
  41. +1 −1 lib/rules/no-arrow-condition.js
  42. +1 −1 lib/rules/no-class-assign.js
  43. +1 −1 lib/rules/no-const-assign.js
  44. +1 −1 lib/rules/no-dupe-class-members.js
  45. +1 −1 lib/rules/no-empty-label.js
  46. +1 −1 lib/rules/no-fallthrough.js
  47. +6 −6 lib/rules/no-implicit-coercion.js
  48. +1 −1 lib/rules/no-invalid-this.js
  49. +1 −1 lib/rules/no-negated-in-lhs.js
  50. +1 −1 lib/rules/no-redeclare.js
  51. +1 −1 lib/rules/no-restricted-syntax.js
  52. +1 −1 lib/rules/no-shadow-restricted-names.js
  53. +1 −1 lib/rules/no-shadow.js
  54. +2 −2 lib/rules/no-this-before-super.js
  55. +1 −1 lib/rules/no-undef.js
  56. +3 −3 lib/rules/no-underscore-dangle.js
  57. +1 −1 lib/rules/no-unmodified-loop-condition.js
  58. +1 −1 lib/rules/no-unused-vars.js
  59. +1 −1 lib/rules/no-use-before-define.js
  60. +1 −1 lib/rules/no-useless-call.js
  61. +1 −1 lib/rules/no-warning-comments.js
  62. +1 −1 lib/rules/no-whitespace-before-property.js
  63. +1 −1 lib/rules/prefer-const.js
  64. +1 −1 lib/rules/prefer-rest-params.js
  65. +1 −1 lib/rules/prefer-spread.js
  66. +6 −6 lib/rules/quote-props.js
  67. +1 −1 lib/rules/require-yield.js
  68. +1 −1 lib/rules/space-after-keywords.js
  69. +2 −2 lib/rules/space-before-keywords.js
  70. +1 −1 lib/rules/space-return-throw-case.js
  71. +6 −6 lib/rules/space-unary-ops.js
  72. +3 −3 lib/rules/spaced-comment.js
  73. +6 −6 lib/rules/strict.js
  74. +1 −1 lib/rules/vars-on-top.js
  75. +6 −6 tests/lib/cli-engine.js
  76. +16 −16 tests/lib/rules/block-scoped-var.js
  77. +75 −75 tests/lib/rules/block-spacing.js
  78. +22 −22 tests/lib/rules/constructor-super.js
  79. +52 −52 tests/lib/rules/key-spacing.js
  80. +6 −6 tests/lib/rules/no-arrow-condition.js
  81. +8 −8 tests/lib/rules/no-class-assign.js
  82. +12 −12 tests/lib/rules/no-const-assign.js
  83. +7 −7 tests/lib/rules/no-dupe-class-members.js
  84. +1 −1 tests/lib/rules/no-empty-label.js
  85. +3 −3 tests/lib/rules/no-fallthrough.js
  86. +13 −13 tests/lib/rules/no-implicit-coercion.js
  87. +2 −2 tests/lib/rules/no-invalid-this.js
  88. +1 −1 tests/lib/rules/no-negated-in-lhs.js
  89. +21 −21 tests/lib/rules/no-redeclare.js
  90. +6 −6 tests/lib/rules/no-restricted-syntax.js
  91. +36 −36 tests/lib/rules/no-shadow-restricted-names.js
  92. +49 −49 tests/lib/rules/no-shadow.js
  93. +14 −14 tests/lib/rules/no-this-before-super.js
  94. +13 −13 tests/lib/rules/no-undef.js
  95. +7 −7 tests/lib/rules/no-underscore-dangle.js
  96. +10 −10 tests/lib/rules/no-unmodified-loop-condition.js
  97. +55 −55 tests/lib/rules/no-unused-vars.js
  98. +36 −36 tests/lib/rules/no-use-before-define.js
  99. +15 −15 tests/lib/rules/no-useless-call.js
  100. +17 −17 tests/lib/rules/no-warning-comments.js
  101. +44 −44 tests/lib/rules/no-whitespace-before-property.js
  102. +18 −18 tests/lib/rules/prefer-const.js
  103. +1 −1 tests/lib/rules/prefer-rest-params.js
  104. +1 −1 tests/lib/rules/prefer-spread.js
  105. +17 −17 tests/lib/rules/quote-props.js
  106. +1 −1 tests/lib/rules/require-yield.js
  107. +22 −22 tests/lib/rules/space-after-keywords.js
  108. +2 −2 tests/lib/rules/space-before-keywords.js
  109. +3 −3 tests/lib/rules/space-return-throw-case.js
  110. +23 −23 tests/lib/rules/space-unary-ops.js
  111. +21 −21 tests/lib/rules/spaced-comment.js
  112. +41 −41 tests/lib/rules/strict.js
  113. +17 −17 tests/lib/rules/vars-on-top.js
  114. +1 −1 tests/lib/util/source-code.js
@@ -26,7 +26,7 @@ function doSomething() {
var build = true;
}
console.log(build); /*error "build" used outside of binding context.*/
console.log(build); /*error 'build' used outside of binding context.*/
}
```

@@ -35,9 +35,9 @@ function doSomething() {
function doSomething() {
if (true) {
var build = true; /*error "build" used outside of binding context.*/
var build = true; /*error 'build' used outside of binding context.*/
} else {
var build = false; /*error "build" used outside of binding context.*/
var build = false; /*error 'build' used outside of binding context.*/
}
}
```
@@ -49,7 +49,7 @@ function doAnother() {
try {
var build = 1;
} catch (e) {
var f = build; /*error "build" used outside of binding context.*/
var f = build; /*error 'build' used outside of binding context.*/
}
}
```
@@ -24,8 +24,8 @@ The following patterns are considered problems:

```js
/*eslint block-spacing: 2*/
function foo() {return true;} /*error Requires a space after "{".*/ /*error Requires a space before "}".*/
if (foo) { bar = 0;} /*error Requires a space before "}".*/
function foo() {return true;} /*error Requires a space after '{'.*/ /*error Requires a space before '}'.*/
if (foo) { bar = 0;} /*error Requires a space before '}'.*/
```

The following patterns are not considered problems:
@@ -50,8 +50,8 @@ The following patterns are considered problems:
```js
/*eslint block-spacing: [2, "never"]*/
function foo() { return true; } /*error Unexpected space(s) after "{".*/ /*error Unexpected space(s) before "}".*/
if (foo) { bar = 0;} /*error Unexpected space(s) after "{".*/
function foo() { return true; } /*error Unexpected space(s) after '{'.*/ /*error Unexpected space(s) before '}'.*/
if (foo) { bar = 0;} /*error Unexpected space(s) after '{'.*/
```

The following patterns are not considered problems:
@@ -18,18 +18,18 @@ The following patterns are considered problems:
class A {
constructor() {
super(); /*error unexpected `super()`.*/
super(); /*error unexpected 'super()'.*/
}
}
class A extends null {
constructor() {
super(); /*error unexpected `super()`.*/
super(); /*error unexpected 'super()'.*/
}
}
class A extends B {
constructor() { } /*error this constructor requires `super()`.*/
constructor() { } /*error this constructor requires 'super()'.*/
}
```

@@ -47,20 +47,20 @@ The following patterns are considered problems:
```js
/*eslint key-spacing: [2, {"beforeColon": false, "afterColon": false}]*/
var obj = { foo: 42 }; /*error Extra space before value for key "foo".*/
var bar = { baz :52 }; /*error Extra space after key "baz".*/
var obj = { foo: 42 }; /*error Extra space before value for key 'foo'.*/
var bar = { baz :52 }; /*error Extra space after key 'baz'.*/
foo = { thisLineWouldBeTooLong:
soUseAnotherLine }; /*error Extra space before value for key "thisLineWouldBeTooLong".*/
soUseAnotherLine }; /*error Extra space before value for key 'thisLineWouldBeTooLong'.*/
```

```js
/*eslint key-spacing: [2, {"beforeColon": true, "afterColon": true}]*/
function foo() {
return {
foobar: 42, /*error Missing space after key "foobar".*/
bat :"value" /*error Missing space before value for key "bat".*/
foobar: 42, /*error Missing space after key 'foobar'.*/
bat :"value" /*error Missing space before value for key 'bat'.*/
};
}
```
@@ -70,8 +70,8 @@ function foo() {
function foo() {
return {
foobar : 42, /*error Extra space after key "foobar".*/
bat : "value" /*error Extra space before value for key "bat".*/
foobar : 42, /*error Extra space after key 'foobar'.*/
bat : "value" /*error Extra space before value for key 'bat'.*/
};
}
```
@@ -115,9 +115,9 @@ The following patterns are considered problems:
/*eslint key-spacing: [2, { "align": "value" }]*/
var obj = {
a: value, /*error Missing space before value for key "a".*/
bcde: 42, /*error Extra space before value for key "bcde".*/
fg : foo() /*error Extra space after key "fg".*/
a: value, /*error Missing space before value for key 'a'.*/
bcde: 42, /*error Extra space before value for key 'bcde'.*/
fg : foo() /*error Extra space after key 'fg'.*/
};
```

@@ -156,9 +156,9 @@ The following patterns are considered problems:
/*eslint key-spacing: [2, { "align": "colon" }]*/
var obj = {
one: 1, /*error Missing space after key "one".*/ /*error Extra space before value for key "one".*/
one: 1, /*error Missing space after key 'one'.*/ /*error Extra space before value for key 'one'.*/
"two": 2,
three: 3 /*error Extra space before value for key "three".*/
three: 3 /*error Extra space before value for key 'three'.*/
};
```

@@ -22,14 +22,14 @@ The following patterns are considered problems:
/*eslint-env es6*/
class A { }
A = 0; /*error `A` is a class.*/
A = 0; /*error 'A' is a class.*/
```

```js
/*eslint no-class-assign: 2*/
/*eslint-env es6*/
A = 0; /*error `A` is a class.*/
A = 0; /*error 'A' is a class.*/
class A { }
```

@@ -39,7 +39,7 @@ class A { }
class A {
b() {
A = 0; /*error `A` is a class.*/
A = 0; /*error 'A' is a class.*/
}
}
```
@@ -50,7 +50,7 @@ class A {
let A = class A {
b() {
A = 0; /*error `A` is a class.*/
A = 0; /*error 'A' is a class.*/
// `let A` is shadowed by the class name.
}
}
@@ -16,23 +16,23 @@ The following patterns are considered problems:
/*eslint-env es6*/
const a = 0;
a = 1; /*error `a` is constant.*/
a = 1; /*error 'a' is constant.*/
```

```js
/*eslint no-const-assign: 2*/
/*eslint-env es6*/
const a = 0;
a += 1; /*error `a` is constant.*/
a += 1; /*error 'a' is constant.*/
```

```js
/*eslint no-const-assign: 2*/
/*eslint-env es6*/
const a = 0;
++a; /*error `a` is constant.*/
++a; /*error 'a' is constant.*/
```

The following patterns are not considered problems:
@@ -27,17 +27,17 @@ The following patterns are considered problems:
class Foo {
bar() { }
bar() { } /*error Duplicate name "bar".*/
bar() { } /*error Duplicate name 'bar'.*/
}
class Foo {
bar() { }
get bar() { } /*error Duplicate name "bar".*/
get bar() { } /*error Duplicate name 'bar'.*/
}
class Foo {
static bar() { }
static bar() { } /*error Duplicate name "bar".*/
static bar() { } /*error Duplicate name 'bar'.*/
}
```

@@ -12,7 +12,7 @@ The following patterns are considered problems:
```js
/*eslint no-empty-label: 2*/
labeled: /*error Unexpected label "labeled"*/
labeled: /*error Unexpected label 'labeled'*/
var x = 10;
```

@@ -68,7 +68,7 @@ The following patterns are considered problems:
/*eslint no-fallthrough: 2*/
switch(foo) {
case 1: /*error Expected a "break" statement before "case".*/
case 1: /*error Expected a 'break' statement before 'case'.*/
doSomething();
case 2:
@@ -52,8 +52,8 @@ The following patterns are considered problems:
```js
/*eslint no-implicit-coercion: 2*/
var b = !!foo; /*error use `Boolean(foo)` instead.*/
var b = ~foo.indexOf("."); /*error use `foo.indexOf(".") !== -1` instead.*/
var b = !!foo; /*error use 'Boolean(foo)' instead.*/
var b = ~foo.indexOf("."); /*error use 'foo.indexOf(".") !== -1' instead.*/
// only with `indexOf`/`lastIndexOf` method calling.
```
@@ -76,8 +76,8 @@ The following patterns are considered problems:
```js
/*eslint no-implicit-coercion: 2*/
var n = +foo; /*error use `Number(foo)` instead.*/
var n = 1 * foo; /*error use `Number(foo)` instead.*/
var n = +foo; /*error use 'Number(foo)' instead.*/
var n = 1 * foo; /*error use 'Number(foo)' instead.*/
```

The following patterns are not considered problems:
@@ -97,9 +97,9 @@ The following patterns are considered problems:
```js
/*eslint no-implicit-coercion: 2*/
var n = "" + foo; /*error use `String(foo)` instead.*/
var n = "" + foo; /*error use 'String(foo)' instead.*/
foo += ""; /*error use `foo = String(foo)` instead.*/
foo += ""; /*error use 'foo = String(foo)' instead.*/
```

The following patterns are not considered problems:
@@ -36,47 +36,47 @@ Please note your code in ES2015 Modules/Classes is always the strict mode.
/*eslint no-invalid-this: 2*/
/*eslint-env es6*/
this.a = 0; /*error Unexpected `this`.*/
baz(() => this); /*error Unexpected `this`.*/
this.a = 0; /*error Unexpected 'this'.*/
baz(() => this); /*error Unexpected 'this'.*/
(function() {
this.a = 0; /*error Unexpected `this`.*/
baz(() => this); /*error Unexpected `this`.*/
this.a = 0; /*error Unexpected 'this'.*/
baz(() => this); /*error Unexpected 'this'.*/
})();
function foo() {
this.a = 0; /*error Unexpected `this`.*/
baz(() => this); /*error Unexpected `this`.*/
this.a = 0; /*error Unexpected 'this'.*/
baz(() => this); /*error Unexpected 'this'.*/
}
var foo = function() {
this.a = 0; /*error Unexpected `this`.*/
baz(() => this); /*error Unexpected `this`.*/
this.a = 0; /*error Unexpected 'this'.*/
baz(() => this); /*error Unexpected 'this'.*/
};
foo(function() {
this.a = 0; /*error Unexpected `this`.*/
baz(() => this); /*error Unexpected `this`.*/
this.a = 0; /*error Unexpected 'this'.*/
baz(() => this); /*error Unexpected 'this'.*/
});
obj.foo = () => {
// `this` of arrow functions is the outer scope's.
this.a = 0; /*error Unexpected `this`.*/
this.a = 0; /*error Unexpected 'this'.*/
};
var obj = {
aaa: function() {
return function foo() {
// There is in a method `aaa`, but `foo` is not a method.
this.a = 0; /*error Unexpected `this`.*/
baz(() => this); /*error Unexpected `this`.*/
this.a = 0; /*error Unexpected 'this'.*/
baz(() => this); /*error Unexpected 'this'.*/
};
}
};
foo.forEach(function() {
this.a = 0; /*error Unexpected `this`.*/
baz(() => this); /*error Unexpected `this`.*/
this.a = 0; /*error Unexpected 'this'.*/
baz(() => this); /*error Unexpected 'this'.*/
});
```

@@ -31,7 +31,7 @@ The following patterns are considered problems:
```js
/*eslint no-negated-in-lhs: 2*/
if(!a in b) { /*error The `in` expression's left operand is negated*/
if(!a in b) { /*error The 'in' expression's left operand is negated*/
// do something
}
```
@@ -12,7 +12,7 @@ The following patterns are considered problems:
/*eslint no-redeclare: 2*/
var a = 3;
var a = 10; /*error "a" is already defined*/
var a = 10; /*error 'a' is already defined*/
```

The following patterns are not considered problems:
@@ -45,7 +45,7 @@ When `{"builtinGlobals": true}`, the following patterns are considered problems:
```js
/*eslint no-redeclare: [2, { "builtinGlobals": true }]*/
var Object = 0; /*error "Object" is already defined*/
var Object = 0; /*error 'Object' is already defined*/
```

When `{"builtinGlobals": true}` and under `browser` environment, the following patterns are considered problems:
@@ -54,7 +54,7 @@ When `{"builtinGlobals": true}` and under `browser` environment, the following p
/*eslint-env browser*/
/*eslint no-redeclare: [2, { "builtinGlobals": true }]*/
var top = 0; /*error "top" is already defined*/
var top = 0; /*error 'top' is already defined*/
```

* Note: The `browser` environment has many built-in global variables, `top` is one of them.
@@ -25,11 +25,11 @@ The following patterns are considered problems:
```js
/* eslint no-restricted-syntax: [2, "FunctionExpression", "WithStatement"] */
with (me) { /*error Using "WithStatement" is not allowed.*/
with (me) { /*error Using 'WithStatement' is not allowed.*/
dontMess();
}
var doSomething = function () {}; /*error Using "FunctionExpression" is not allowed.*/
var doSomething = function () {}; /*error Using 'FunctionExpression' is not allowed.*/
```

The following patterns are not considered problems:
Oops, something went wrong.

0 comments on commit 58715e9

Please sign in to comment.
You can’t perform that action at this time.