This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add jsx-ignore option to no-magic-numbers rule (#4460)
* add jsx-ignore option * address feedback * feedback - parse options, add additional test case * feedback - fix conditional * feedback - use continue in loop instead
- Loading branch information
Liz
authored and
Josh Goldberg
committed
Feb 3, 2019
1 parent
a2c67a7
commit 5670c44
Showing
7 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
parseInt(); | ||
parseInt('123', 2); | ||
parseInt('123', 8); | ||
parseInt('123', 10); | ||
parseInt('123', 16); | ||
console.log(-0); | ||
console.log(1337); | ||
console.log(-1337); | ||
console.log(- 1337); | ||
console.log(1337.7); | ||
console.log(1338); | ||
~~~~ ['magic numbers' are not allowed: 1338] | ||
console.log(-1338) | ||
~~~~~ ['magic numbers' are not allowed: -1338] | ||
parseInt(foo === 4711 ? bar : baz, 10); | ||
~~~~ ['magic numbers' are not allowed: 4711] | ||
parseInt(foo === -0 ? bar : baz, 10); | ||
export let x = 1337; | ||
export let x = -1337; | ||
export let x = 1337.7; | ||
export let x = 1338; | ||
export let x = -1338; | ||
export let x = -0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"rules": { | ||
"no-magic-numbers": [true, { | ||
"allowed-numbers": [1337, 1337.7, -1337, -0] | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as React from "react"; | ||
class App extends React.Component { | ||
render() { | ||
return <Component width={200} height={200} />; | ||
~~~ ['magic numbers' are not allowed: 200] | ||
~~~ ['magic numbers' are not allowed: 200] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"no-magic-numbers": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from "react"; | ||
class App extends React.Component { | ||
render() { | ||
return <Component width={200} height={200} />; | ||
} | ||
} | ||
|
||
function something(num) {} | ||
something(100) | ||
~~~ ['magic numbers' are not allowed: 100] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"rules": { | ||
"no-magic-numbers": [true, { | ||
"ignore-jsx": true | ||
}] | ||
} | ||
} |