Skip to content

Commit

Permalink
eslint plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed May 13, 2024
1 parent af65d7d commit c32dac7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions packages/eslint-plugin/rules/__tests__/wp-global-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ ruleTester.run( 'wp-global-usage', rule, {
valid: [
{ code: "const text = 'SCRIPT_DEBUG'" },
{ code: 'const config = { SCRIPT_DEBUG: true }' },
{ code: `if ( globalThis.IS_GUTENBERG_PLUGIN ) {}` },
{ code: `if ( globalThis.IS_WORDPRESS_CORE ) {}` },
{ code: `if ( globalThis.SCRIPT_DEBUG ) {}` },
{ code: `if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {}` },
{ code: 'if ( globalThis.IS_GUTENBERG_PLUGIN ) {}' },
{ code: 'if ( globalThis.IS_WORDPRESS_CORE ) {}' },
{ code: 'if ( globalThis.SCRIPT_DEBUG ) {}' },
{ code: 'if ( process.env.SCRIPT_DEBUG ) {}' },
{ code: 'if ( ! globalThis.IS_GUTENBERG_PLUGIN ) {}' },
{
// Ensure whitespace is ok.
code: `if (
globalThis.
IS_GUTENBERG_PLUGIN
) {}`,
},
{ code: `const test = globalThis.IS_GUTENBERG_PLUGIN ? foo : bar` },
{ code: `const test = ! globalThis.IS_GUTENBERG_PLUGIN ? bar : foo` },
{ code: 'const test = globalThis.IS_GUTENBERG_PLUGIN ? foo : bar' },
{ code: 'const test = ! globalThis.IS_GUTENBERG_PLUGIN ? bar : foo' },
{
// Ensure whitespace is ok.
code: `const test = ! globalThis.
Expand Down Expand Up @@ -89,7 +90,7 @@ ruleTester.run( 'wp-global-usage', rule, {
output: 'if ( globalThis.IS_GUTENBERG_PLUGIN ) {}',
},
{
code: `if ( true ) { globalThis.IS_GUTENBERG_PLUGIN === 2 }`,
code: 'if ( true ) { globalThis.IS_GUTENBERG_PLUGIN === 2 }',
errors: [
{
messageId: 'usedOutsideConditional',
Expand All @@ -98,7 +99,7 @@ ruleTester.run( 'wp-global-usage', rule, {
],
},
{
code: `if ( globalThis.IS_GUTENBERG_PLUGIN === 2 ) {}`,
code: 'if ( globalThis.IS_GUTENBERG_PLUGIN === 2 ) {}',
errors: [
{
messageId: 'usedOutsideConditional',
Expand All @@ -107,7 +108,7 @@ ruleTester.run( 'wp-global-usage', rule, {
],
},
{
code: `if ( true || globalThis.IS_GUTENBERG_PLUGIN === 2 ) {}`,
code: 'if ( true || globalThis.IS_GUTENBERG_PLUGIN === 2 ) {}',
errors: [
{
messageId: 'usedOutsideConditional',
Expand All @@ -116,7 +117,7 @@ ruleTester.run( 'wp-global-usage', rule, {
],
},
{
code: `const isFeatureActive = globalThis.IS_GUTENBERG_PLUGIN;`,
code: 'const isFeatureActive = globalThis.IS_GUTENBERG_PLUGIN;',
errors: [
{
messageId: 'usedOutsideConditional',
Expand Down

0 comments on commit c32dac7

Please sign in to comment.