Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"cross-env": "^6.0.3",
"danger": "^9.2.10",
"error-stack-parser": "^2.0.6",
"eslint": "^6.8.0",
"eslint": "^7.0.0",
"eslint-config-fbjs": "^1.1.1",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-babel": "^5.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ruleTester.run('no-production-logging', rule, {
invalid: [
{
code: "console.error('Oh no');",
output: "if (__DEV__) {console.error('Oh no')};",
errors: [
{
message: `Wrap console.error() in an "if (__DEV__) {}" check`,
Expand All @@ -118,6 +119,7 @@ ruleTester.run('no-production-logging', rule, {
},
{
code: "console.warn('Oh no');",
output: "if (__DEV__) {console.warn('Oh no')};",
errors: [
{
message: `Wrap console.warn() in an "if (__DEV__) {}" check`,
Expand All @@ -126,6 +128,7 @@ ruleTester.run('no-production-logging', rule, {
},
{
code: "console.warn('Oh no')",
output: "if (__DEV__) {console.warn('Oh no')}",
errors: [
{
message: `Wrap console.warn() in an "if (__DEV__) {}" check`,
Expand All @@ -138,6 +141,11 @@ ruleTester.run('no-production-logging', rule, {
console.warn('Oh no');
}
`,
output: `
if (potato) {
if (__DEV__) {console.warn('Oh no')};
}
`,
errors: [
{
message: `Wrap console.warn() in an "if (__DEV__) {}" check`,
Expand All @@ -150,6 +158,11 @@ ruleTester.run('no-production-logging', rule, {
console.error('Oh no');
}
`,
output: `
if (__DEV__ || potato && true) {
if (__DEV__) {console.error('Oh no')};
}
`,
errors: [
{
message: `Wrap console.error() in an "if (__DEV__) {}" check`,
Expand All @@ -162,6 +175,11 @@ ruleTester.run('no-production-logging', rule, {
console.error('Oh no');
}
`,
output: `
if (banana && __DEV__ && potato && kitten) {
if (__DEV__) {console.error('Oh no')};
}
`,
// Technically this code is valid but we prefer
// explicit standalone __DEV__ blocks that stand out.
errors: [
Expand All @@ -176,6 +194,11 @@ ruleTester.run('no-production-logging', rule, {
console.error('Oh no');
}
`,
output: `
if (!__DEV__) {
if (__DEV__) {console.error('Oh no')};
}
`,
errors: [
{
message: `Wrap console.error() in an "if (__DEV__) {}" check`,
Expand All @@ -188,6 +211,11 @@ ruleTester.run('no-production-logging', rule, {
console.error('Oh no');
}
`,
output: `
if (foo || x && __DEV__) {
if (__DEV__) {console.error('Oh no')};
}
`,
errors: [
{
message: `Wrap console.error() in an "if (__DEV__) {}" check`,
Expand All @@ -201,6 +229,12 @@ ruleTester.run('no-production-logging', rule, {
console.error('Oh no');
}
`,
output: `
if (__DEV__) {
} else {
if (__DEV__) {console.error('Oh no')};
}
`,
errors: [
{
message: `Wrap console.error() in an "if (__DEV__) {}" check`,
Expand All @@ -217,6 +251,15 @@ ruleTester.run('no-production-logging', rule, {
}
}
`,
output: `
if (__DEV__) {
} else {
if (__DEV__) {
} else {
if (__DEV__) {console.error('Oh no')};
}
}
`,
errors: [
{
message: `Wrap console.error() in an "if (__DEV__) {}" check`,
Expand Down
6 changes: 5 additions & 1 deletion scripts/rollup/validate/eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
**/react-noop-renderer/**
JestReact-prod.js
JestReact-dev.js
**/jest-react/**
**/jest-react/**
# ESLint ignores `node_modules/*` in subdirectories
# So we have to add this to lint build files.
# https://github.com/eslint/eslint/pull/12888
!/build/node_modules/*
Loading