Skip to content

Commit

Permalink
Fix rollup validate script (#18900)
Browse files Browse the repository at this point in the history
* Revert "Revert "deps: update ESLint version to v7 (#18897)" (#18899)"

This reverts commit 84fd4b8.

* fix rollup validate script
  • Loading branch information
koba04 authored May 27, 2020
1 parent 8abc202 commit fb73542
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 31 deletions.
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

0 comments on commit fb73542

Please sign in to comment.