Skip to content

Commit 13be022

Browse files
committed
[eslint] enable and manually fix no-useless-escape
1 parent 3d19e2f commit 13be022

File tree

10 files changed

+12
-13
lines changed

10 files changed

+12
-13
lines changed

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
"prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
2828

29-
"no-useless-escape": 1,
3029
"function-paren-newline": 0,
3130
"no-plusplus": 1,
3231
"no-param-reassign": 1,

lib/rules/forbid-elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module.exports = {
104104

105105
if (argType === 'Identifier' && /^[A-Z_]/.test(argument.name)) {
106106
reportIfForbidden(argument.name, argument);
107-
} else if (argType === 'Literal' && /^[a-z][^\.]*$/.test(argument.value)) {
107+
} else if (argType === 'Literal' && /^[a-z][^.]*$/.test(argument.value)) {
108108
reportIfForbidden(argument.value, argument);
109109
} else if (argType === 'MemberExpression') {
110110
reportIfForbidden(sourceCode.getText(argument), argument);

lib/util/error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param {String} message - Message to log.
66
*/
77
function error(message) {
8-
if (!/\=-(f|-format)=/.test(process.argv.join('='))) {
8+
if (!/=-(f|-format)=/.test(process.argv.join('='))) {
99
// eslint-disable-next-line no-console
1010
console.error(message);
1111
}

lib/util/jsx.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
const elementType = require('jsx-ast-utils/elementType');
88

9-
const COMPAT_TAG_REGEX = /^[a-z]|\-/;
9+
const COMPAT_TAG_REGEX = /^[a-z]|-/;
1010

1111
/**
1212
* Checks if a node represents a DOM element.

lib/util/log.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param {String} message - Message to log.
66
*/
77
function log(message) {
8-
if (!/\=-(f|-format)=/.test(process.argv.join('='))) {
8+
if (!/=-(f|-format)=/.test(process.argv.join('='))) {
99
// eslint-disable-next-line no-console
1010
console.log(message);
1111
}

lib/util/propTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function isSuperTypeParameterPropsDeclaration(node) {
3030
* @param {string} string the identifier to strip
3131
*/
3232
function stripQuotes(string) {
33-
return string.replace(/^\'|\'$/g, '');
33+
return string.replace(/^'|'$/g, '');
3434
}
3535

3636
/**

lib/util/usedPropTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ module.exports = function usedPropTypesInstructions(context, components, utils)
181181
* @param {string} string the identifier to strip
182182
*/
183183
function stripQuotes(string) {
184-
return string.replace(/^\'|\'$/g, '');
184+
return string.replace(/^'|'$/g, '');
185185
}
186186

187187
/**

tests/lib/rules/no-unescaped-entities.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ ruleTester.run('no-unescaped-entities', rule, {
199199
});
200200
`,
201201
parser: parsers.BABEL_ESLINT,
202-
errors: [{message: 'HTML entity, \`&\` , must be escaped.'}],
202+
errors: [{message: 'HTML entity, `&` , must be escaped.'}],
203203
options: [{
204204
forbid: ['&']
205205
}]
@@ -211,7 +211,7 @@ ruleTester.run('no-unescaped-entities', rule, {
211211
}
212212
});
213213
`,
214-
errors: [{message: 'HTML entity, \`&\` , must be escaped.'}],
214+
errors: [{message: 'HTML entity, `&` , must be escaped.'}],
215215
options: [{
216216
forbid: ['&']
217217
}]

tests/lib/rules/no-unused-prop-types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,10 +2642,10 @@ ruleTester.run('no-unused-prop-types', rule, {
26422642
}, {
26432643
code: `
26442644
type Props = {
2645-
\'completed?\': boolean,
2645+
'completed?': boolean,
26462646
};
26472647
const Hello = (props: Props): React.Element => {
2648-
return <div>{props[\'completed?\']}</div>;
2648+
return <div>{props['completed?']}</div>;
26492649
}
26502650
`,
26512651
parser: parsers.BABEL_ESLINT

tests/lib/rules/no-unused-state.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ eslintTester.run('no-unused-state', rule, {
344344
this.state = { foo: 0, bar: 1 };
345345
}
346346
render() {
347-
const bar = \'bar\';
347+
const bar = 'bar';
348348
return <SomeComponent bar={this.state[bar]} />;
349349
}
350350
}`,
@@ -1016,7 +1016,7 @@ eslintTester.run('no-unused-state', rule, {
10161016
const foo = ((this: any).state: any).foo;
10171017
const {bar, ...others} = (this.state: any);
10181018
let baz;
1019-
baz = (others: any)[\'baz\'];
1019+
baz = (others: any)['baz'];
10201020
return <SomeComponent foo={foo} bar={bar} baz={baz} />;
10211021
}
10221022
}`,

0 commit comments

Comments
 (0)