Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint: Copy no-restricted-syntax rules from ESLint plugin to config file #15877

Merged
merged 1 commit into from May 29, 2019

Conversation

@tfrommen
Copy link
Member

commented May 29, 2019

Description

As discussed in #15839, this PR copies the custom rules/options to the Gutenberg ESLint config.

How has this been tested?

Create a file test.js with this content:

const { __experimentalGetSettings } = wp.date;
const { __, _n, _nx, _x } = wp.i18n;

const foo_x = () => {};

const foo = 'bar';

/**
 * Should NOT flag
 */
__( 'Some text', 'text-domain' );
_n( 'Some text', 'Some texts', 42, 'text-domain' );
_nx( 'Some text', 'Some texts', 42, 'Some context', 'text-domain' );
_x( 'Some text', 'Some context', 'text-domain' );
const settings = __experimentalGetSettings();
foo_x();

/**
 * SHOULD flag
 */
__( foo, 'text-domain' );
_n( foo, 'Some texts', 42, 'text-domain' );
_nx( foo, 'Some texts', 42, 'Some context', 'text-domain' );
_x( foo, 'Some context', 'text-domain' );

_n( 'Some text', foo, 42, 'text-domain' );
_nx( 'Some texts', foo, 42, 'Some context', 'text-domain' );
_x( 'Some text', foo, 'text-domain' );

_nx( 'Some text', 'Some texts', 42, foo, 'text-domain' );

Then call:

./node_modules/.bin/eslint test.js

Types of changes

Copy ESLint rules/options that are defined in the ESLint plugin, but overriden in the Gutenberg ESLint config.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
Copy no-restricted-syntax rules from ESLint plugin to config file
Also, remove unused import of lodash.map

@tfrommen tfrommen self-assigned this May 29, 2019

@tfrommen tfrommen requested review from aduth, gziolo, swissspidy and ntwb May 29, 2019

@gziolo gziolo added this to the 5.9 (Gutenberg) milestone May 29, 2019

@gziolo

gziolo approved these changes May 29, 2019

Copy link
Member

left a comment

Thanks for wrangling it. Let's merge when Travis is green.

@@ -1,7 +1,7 @@
/**
* External dependencies
*/
const { escapeRegExp, map } = require( 'lodash' );
const { escapeRegExp } = require( 'lodash' );

This comment has been minimized.

Copy link
@gziolo

gziolo May 29, 2019

Member

That's surprising, it should error in master...

This comment has been minimized.

Copy link
@swissspidy

swissspidy May 29, 2019

Member
$ ./node_modules/.bin/eslint .eslintrc.js

/Users/pascalb/Workspace/WordPress/gutenberg/.eslintrc.js
  0:0  warning  File ignored by default.  Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'") to override

✖ 1 problem (0 errors, 1 warning)

That explains it :-)

This comment has been minimized.

Copy link
@tfrommen

tfrommen May 29, 2019

Author Member

I was wondering the same, but reason is that the .eslintrc.js file is, by default, ignored. So ESLint doesn't check it.

This comment has been minimized.

Copy link
@gziolo

gziolo May 29, 2019

Member

Nice, good to know 😃

This comment has been minimized.

Copy link
@aduth

aduth May 29, 2019

Member

I was wondering the same, but reason is that the .eslintrc.js file is, by default, ignored. So ESLint doesn't check it.

Can we change this? Not immediately obvious why we'd want it to be exempt.

This comment has been minimized.

Copy link
@tfrommen

tfrommen May 29, 2019

Author Member

@aduth sure, I'll create a PR for that. See #15887.

@gziolo gziolo merged commit 48afde8 into master May 29, 2019

1 check passed

Travis CI - Pull Request Build Passed
Details

@gziolo gziolo deleted the translate-function-arguments-eslint-rules branch May 29, 2019

@gwwar gwwar referenced this pull request Jun 22, 2019

Open

Post author dropdown: add accessible-autocomplete #7385

4 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.