@wordpress/eslint-plugin 9.3.0 → 10.0.1-next.f435e9e01b.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/LICENSE.md +1 -1
- package/README.md +26 -18
- package/configs/custom.js +2 -5
- package/configs/esnext.js +25 -4
- package/configs/react.js +3 -1
- package/configs/recommended-with-formatting.js +13 -2
- package/configs/recommended.js +0 -2
- package/package.json +16 -14
- package/rules/__tests__/i18n-hyphenated-range.js +63 -0
- package/rules/__tests__/i18n-no-flanking-whitespace.js +77 -0
- package/rules/__tests__/is-gutenberg-plugin.js +65 -0
- package/rules/data-no-store-string-literals.js +1 -0
- package/rules/gutenberg-phase.js +2 -0
- package/rules/i18n-hyphenated-range.js +101 -0
- package/rules/i18n-no-flanking-whitespace.js +91 -0
- package/rules/is-gutenberg-plugin.js +94 -0
- package/rules/__tests__/gutenberg-phase.js +0 -63
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 10.0.0 (2022-01-27)
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- The peer dependency constraint for ESLint has been updated from `^6 || ^7` to `^8`.
|
|
10
|
+
- The bundled `@typescript-eslint/eslint-plugin` dependency has been updated from requiring `^4.31.0` to requiring `^5.3.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
|
|
11
|
+
- The bundled `@typescript-eslint/parser` dependency has been updated from requiring `^4.31.0` to requiring `^5.3.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
|
|
12
|
+
- The bundled `eslint-config-prettier` dependency has been updated from requiring `^7.1.0` to requiring `^8.3.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
|
|
13
|
+
- The bundled `eslint-plugin-jest` dependency has been updated from requiring `^24.1.3` to requiring `^25.2.3` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
|
|
14
|
+
- The bundled `eslint-plugin-jsdoc` dependency has been updated from requiring `^36.0.8` to requiring `^37.0.3` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
|
|
15
|
+
- The bundled `globals` dependency has been updated from requiring `^12.0.0` to requiring `^13.12.0` ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
|
|
16
|
+
- The `gutenberg-phase` rule has been deprecated and replaced by the `is-gutenberg-plugin` rule. ([#38202](https://github.com/WordPress/gutenberg/pull/38202))
|
|
17
|
+
|
|
18
|
+
### Enhancement
|
|
19
|
+
|
|
20
|
+
- Omit verification for WordPress dependencies in the import statements since they get externalized when used with WordPress ([#37639](https://github.com/WordPress/gutenberg/pull/37639)).
|
|
21
|
+
|
|
22
|
+
### Bug Fix
|
|
23
|
+
|
|
24
|
+
- Fix Babel config resolution when a custom ESLint config present ([#37406](https://github.com/WordPress/gutenberg/pull/37406)). Warning: it won't recognize the `babel.config.json` file present in the project until the upstream bug in `cosmiconfig` is fixed.
|
|
25
|
+
|
|
5
26
|
## 9.3.0 (2021-11-15)
|
|
6
27
|
|
|
7
28
|
### Enhancements
|
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -56,23 +56,25 @@ The granular rulesets will not define any environment globals. As such, if they
|
|
|
56
56
|
|
|
57
57
|
### Rules
|
|
58
58
|
|
|
59
|
-
| Rule
|
|
60
|
-
|
|
|
61
|
-
| [data-no-store-string-literals](/packages/eslint-plugin/docs/rules/data-no-store-string-literals.md) | Discourage passing string literals to reference data stores | |
|
|
62
|
-
| [dependency-group](/packages/eslint-plugin/docs/rules/dependency-group.md) | Enforce dependencies docblocks formatting | ✓ |
|
|
63
|
-
| [gutenberg-
|
|
64
|
-
| [no-base-control-with-label-without-id](/packages/eslint-plugin/docs/rules/no-base-control-with-label-without-id.md) | Disallow the usage of BaseControl component with a label prop set but omitting the id property | ✓ |
|
|
65
|
-
| [no-unguarded-get-range-at](/packages/eslint-plugin/docs/rules/no-unguarded-get-range-at.md) | Disallow the usage of unguarded `getRangeAt` calls | ✓ |
|
|
66
|
-
| [no-unsafe-wp-apis](/packages/eslint-plugin/docs/rules/no-unsafe-wp-apis.md) | Disallow the usage of unsafe APIs from `@wordpress/*` packages | ✓ |
|
|
67
|
-
| [no-unused-vars-before-return](/packages/eslint-plugin/docs/rules/no-unused-vars-before-return.md) | Disallow assigning variable values if unused before a return | ✓ |
|
|
68
|
-
| [react-no-unsafe-timeout](/packages/eslint-plugin/docs/rules/react-no-unsafe-timeout.md) | Disallow unsafe `setTimeout` in component | |
|
|
69
|
-
| [valid-sprintf](/packages/eslint-plugin/docs/rules/valid-sprintf.md) | Enforce valid sprintf usage | ✓ |
|
|
70
|
-
| [i18n-ellipsis](/packages/eslint-plugin/docs/rules/i18n-ellipsis.md) | Disallow using three dots in translatable strings | ✓ |
|
|
71
|
-
| [i18n-no-collapsible-whitespace](/packages/eslint-plugin/docs/rules/i18n-no-collapsible-whitespace.md) | Disallow collapsible whitespace in translatable strings | ✓ |
|
|
72
|
-
| [i18n-no-placeholders-only](/packages/eslint-plugin/docs/rules/i18n-no-placeholders-only.md) | Prevent using only placeholders in translatable strings | ✓ |
|
|
73
|
-
| [i18n-no-variables](/packages/eslint-plugin/docs/rules/i18n-no-variables.md) | Enforce string literals as translation function arguments | ✓ |
|
|
74
|
-
| [i18n-text-domain](/packages/eslint-plugin/docs/rules/i18n-text-domain.md) | Enforce passing valid text domains | ✓ |
|
|
75
|
-
| [i18n-translator-comments](/packages/eslint-plugin/docs/rules/i18n-translator-comments.md) | Enforce adding translator comments | ✓ |
|
|
59
|
+
| Rule | Description | Recommended |
|
|
60
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ----------- |
|
|
61
|
+
| [data-no-store-string-literals](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/data-no-store-string-literals.md) | Discourage passing string literals to reference data stores | |
|
|
62
|
+
| [dependency-group](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/dependency-group.md) | Enforce dependencies docblocks formatting | ✓ |
|
|
63
|
+
| [is-gutenberg-plugin](docs/rules/is-gutenberg-plugin.md) | Governs the use of the `process.env.IS_GUTENBERG_PLUGIN` constant | ✓ |
|
|
64
|
+
| [no-base-control-with-label-without-id](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-base-control-with-label-without-id.md) | Disallow the usage of BaseControl component with a label prop set but omitting the id property | ✓ |
|
|
65
|
+
| [no-unguarded-get-range-at](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unguarded-get-range-at.md) | Disallow the usage of unguarded `getRangeAt` calls | ✓ |
|
|
66
|
+
| [no-unsafe-wp-apis](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unsafe-wp-apis.md) | Disallow the usage of unsafe APIs from `@wordpress/*` packages | ✓ |
|
|
67
|
+
| [no-unused-vars-before-return](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unused-vars-before-return.md) | Disallow assigning variable values if unused before a return | ✓ |
|
|
68
|
+
| [react-no-unsafe-timeout](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/react-no-unsafe-timeout.md) | Disallow unsafe `setTimeout` in component | |
|
|
69
|
+
| [valid-sprintf](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/valid-sprintf.md) | Enforce valid sprintf usage | ✓ |
|
|
70
|
+
| [i18n-ellipsis](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/i18n-ellipsis.md) | Disallow using three dots in translatable strings | ✓ |
|
|
71
|
+
| [i18n-no-collapsible-whitespace](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/i18n-no-collapsible-whitespace.md) | Disallow collapsible whitespace in translatable strings | ✓ |
|
|
72
|
+
| [i18n-no-placeholders-only](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/i18n-no-placeholders-only.md) | Prevent using only placeholders in translatable strings | ✓ |
|
|
73
|
+
| [i18n-no-variables](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/i18n-no-variables.md) | Enforce string literals as translation function arguments | ✓ |
|
|
74
|
+
| [i18n-text-domain](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/i18n-text-domain.md) | Enforce passing valid text domains | ✓ |
|
|
75
|
+
| [i18n-translator-comments](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/i18n-translator-comments.md) | Enforce adding translator comments | ✓ |
|
|
76
|
+
| [i18n-no-flanking-whitespace](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/i18n-no-flanking-whitespace.md) | Disallow leading or trailing whitespace in translatable strings | |
|
|
77
|
+
| [i18n-hyphenated-range](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/i18n-hyphenated-range.md) | Disallow hyphenated numerical ranges in translatable strings | |
|
|
76
78
|
|
|
77
79
|
### Legacy
|
|
78
80
|
|
|
@@ -84,4 +86,10 @@ If you are using WordPress' `.jshintrc` JSHint configuration and you would like
|
|
|
84
86
|
}
|
|
85
87
|
```
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
## Contributing to this package
|
|
90
|
+
|
|
91
|
+
This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
|
|
92
|
+
|
|
93
|
+
To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
|
|
94
|
+
|
|
95
|
+
<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
|
package/configs/custom.js
CHANGED
|
@@ -13,6 +13,8 @@ module.exports = {
|
|
|
13
13
|
files: [ '*.native.js' ],
|
|
14
14
|
rules: {
|
|
15
15
|
'@wordpress/no-base-control-with-label-without-id': 'off',
|
|
16
|
+
'@wordpress/i18n-no-flanking-whitespace': 'error',
|
|
17
|
+
'@wordpress/i18n-hyphenated-range': 'error',
|
|
16
18
|
},
|
|
17
19
|
},
|
|
18
20
|
{
|
|
@@ -27,9 +29,4 @@ module.exports = {
|
|
|
27
29
|
},
|
|
28
30
|
},
|
|
29
31
|
],
|
|
30
|
-
settings: {
|
|
31
|
-
react: {
|
|
32
|
-
version: '16.6',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
32
|
};
|
package/configs/esnext.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
const { cosmiconfigSync } = require( 'cosmiconfig' );
|
|
5
|
+
|
|
6
|
+
const config = {
|
|
7
|
+
parser: '@babel/eslint-parser',
|
|
8
|
+
parserOptions: {
|
|
9
|
+
sourceType: 'module',
|
|
10
|
+
},
|
|
2
11
|
env: {
|
|
3
12
|
es6: true,
|
|
4
13
|
},
|
|
5
14
|
extends: [ require.resolve( './es5.js' ) ],
|
|
6
|
-
parserOptions: {
|
|
7
|
-
sourceType: 'module',
|
|
8
|
-
},
|
|
9
15
|
rules: {
|
|
10
16
|
// Disable ES5-specific (extended from ES5)
|
|
11
17
|
'vars-on-top': 'off',
|
|
@@ -45,3 +51,18 @@ module.exports = {
|
|
|
45
51
|
'template-curly-spacing': [ 'error', 'always' ],
|
|
46
52
|
},
|
|
47
53
|
};
|
|
54
|
+
|
|
55
|
+
// It won't recognize the `babel.config.json` file used in the project until the upstream bug in `cosmiconfig` is fixed:
|
|
56
|
+
// https://github.com/davidtheclark/cosmiconfig/issues/246.
|
|
57
|
+
const result = cosmiconfigSync( 'babel' ).search();
|
|
58
|
+
if ( ! result || ! result.filepath ) {
|
|
59
|
+
config.parserOptions = {
|
|
60
|
+
...config.parserOptions,
|
|
61
|
+
requireConfigFile: false,
|
|
62
|
+
babelOptions: {
|
|
63
|
+
presets: [ require.resolve( '@wordpress/babel-preset-default' ) ],
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = config;
|
package/configs/react.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
const { isPackageInstalled } = require( '../utils' );
|
|
5
5
|
|
|
6
|
+
// Exclude bundled WordPress packages from the list.
|
|
7
|
+
const wpPackagesRegExp = '^@wordpress/(?!(icons|interface))';
|
|
8
|
+
|
|
6
9
|
const config = {
|
|
7
|
-
parser: '@babel/eslint-parser',
|
|
8
10
|
extends: [
|
|
9
11
|
require.resolve( './jsx-a11y.js' ),
|
|
10
12
|
require.resolve( './custom.js' ),
|
|
@@ -21,6 +23,10 @@ const config = {
|
|
|
21
23
|
document: true,
|
|
22
24
|
wp: 'readonly',
|
|
23
25
|
},
|
|
26
|
+
settings: {
|
|
27
|
+
'import/internal-regex': wpPackagesRegExp,
|
|
28
|
+
'import/extensions': [ '.js', '.jsx' ],
|
|
29
|
+
},
|
|
24
30
|
rules: {
|
|
25
31
|
'import/no-extraneous-dependencies': [
|
|
26
32
|
'error',
|
|
@@ -28,7 +34,12 @@ const config = {
|
|
|
28
34
|
peerDependencies: true,
|
|
29
35
|
},
|
|
30
36
|
],
|
|
31
|
-
'import/no-unresolved':
|
|
37
|
+
'import/no-unresolved': [
|
|
38
|
+
'error',
|
|
39
|
+
{
|
|
40
|
+
ignore: [ wpPackagesRegExp ],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
32
43
|
'import/default': 'warn',
|
|
33
44
|
'import/named': 'warn',
|
|
34
45
|
},
|
package/configs/recommended.js
CHANGED
|
@@ -21,7 +21,6 @@ const config = {
|
|
|
21
21
|
extends: [
|
|
22
22
|
require.resolve( './recommended-with-formatting.js' ),
|
|
23
23
|
'plugin:prettier/recommended',
|
|
24
|
-
'prettier/react',
|
|
25
24
|
],
|
|
26
25
|
rules: {
|
|
27
26
|
'prettier/prettier': [ 'error', prettierConfig ],
|
|
@@ -35,7 +34,6 @@ if ( isPackageInstalled( 'typescript' ) ) {
|
|
|
35
34
|
extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
|
|
36
35
|
},
|
|
37
36
|
},
|
|
38
|
-
'import/core-modules': [ 'react' ],
|
|
39
37
|
};
|
|
40
38
|
config.extends.push( 'plugin:@typescript-eslint/eslint-recommended' );
|
|
41
39
|
config.ignorePatterns = [ '**/*.d.ts' ];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/eslint-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.1-next.f435e9e01b.0",
|
|
4
4
|
"description": "ESLint plugin for WordPress development.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -32,25 +32,27 @@
|
|
|
32
32
|
"main": "index.js",
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/eslint-parser": "^7.16.0",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
36
|
-
"@typescript-eslint/parser": "^
|
|
37
|
-
"@wordpress/
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
36
|
+
"@typescript-eslint/parser": "^5.3.0",
|
|
37
|
+
"@wordpress/babel-preset-default": "^6.5.1-next.f435e9e01b.0",
|
|
38
|
+
"@wordpress/prettier-config": "^1.1.2-next.f435e9e01b.0",
|
|
38
39
|
"cosmiconfig": "^7.0.0",
|
|
39
|
-
"eslint-config-prettier": "^
|
|
40
|
+
"eslint-config-prettier": "^8.3.0",
|
|
40
41
|
"eslint-plugin-import": "^2.25.2",
|
|
41
|
-
"eslint-plugin-jest": "^
|
|
42
|
-
"eslint-plugin-jsdoc": "^
|
|
43
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
42
|
+
"eslint-plugin-jest": "^25.2.3",
|
|
43
|
+
"eslint-plugin-jsdoc": "^37.0.3",
|
|
44
|
+
"eslint-plugin-jsx-a11y": "^6.5.1",
|
|
44
45
|
"eslint-plugin-prettier": "^3.3.0",
|
|
45
|
-
"eslint-plugin-react": "^7.
|
|
46
|
-
"eslint-plugin-react-hooks": "^4.
|
|
47
|
-
"globals": "^12.0
|
|
46
|
+
"eslint-plugin-react": "^7.27.0",
|
|
47
|
+
"eslint-plugin-react-hooks": "^4.3.0",
|
|
48
|
+
"globals": "^13.12.0",
|
|
48
49
|
"prettier": "npm:wp-prettier@2.2.1-beta-1",
|
|
49
50
|
"requireindex": "^1.2.0"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
53
|
+
"@babel/core": ">=7",
|
|
54
|
+
"eslint": ">=8",
|
|
55
|
+
"typescript": ">=4"
|
|
54
56
|
},
|
|
55
57
|
"peerDependenciesMeta": {
|
|
56
58
|
"typescript": {
|
|
@@ -60,5 +62,5 @@
|
|
|
60
62
|
"publishConfig": {
|
|
61
63
|
"access": "public"
|
|
62
64
|
},
|
|
63
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "14b2846015dfb1b440ce93accdd03842ebe5f1cd"
|
|
64
66
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RuleTester } from 'eslint';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import rule from '../i18n-hyphenated-range';
|
|
10
|
+
|
|
11
|
+
const ruleTester = new RuleTester( {
|
|
12
|
+
parserOptions: {
|
|
13
|
+
ecmaVersion: 6,
|
|
14
|
+
},
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
ruleTester.run( 'i18n-hyphenated-range', rule, {
|
|
18
|
+
valid: [
|
|
19
|
+
{
|
|
20
|
+
code: `__( 'Hyphenated-words are ok' )`,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
code: `__( 'Hyphen - when used in this case - is ok' )`,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
code: `__('en dash – and em dash — are ok')`,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
code: `__( 'en dash – ranges work 1–99 or 2 – 98' )`,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
code: `__( 'Negative numbers like -99 or -33 are ok' )`,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
code: `__( 'Numbers with trailing hyphens are odd but ok like 99-' )`,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
code: `__( '1 0 -1' )`,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
invalid: [
|
|
42
|
+
{
|
|
43
|
+
code: `__( 'guess a number 1 - 10' )`,
|
|
44
|
+
output: `__( 'guess a number 1 – 10' )`,
|
|
45
|
+
errors: [ { messageId: 'foundHyphen' } ],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
code: `__( 'No spaces: 00-99' )`,
|
|
49
|
+
output: `__( 'No spaces: 00–99' )`,
|
|
50
|
+
errors: [ { messageId: 'foundHyphen' } ],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
code: `__( 'From 0 - 2 many spaces in the range' )`,
|
|
54
|
+
output: `__( 'From 0 – 2 many spaces in the range' )`,
|
|
55
|
+
errors: [ { messageId: 'foundHyphen' } ],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
code: `__( '1-2' + ' fixing multiple strings' )`,
|
|
59
|
+
output: `__( '1–2' + ' fixing multiple strings' )`,
|
|
60
|
+
errors: [ { messageId: 'foundHyphen' } ],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
} );
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RuleTester } from 'eslint';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import rule from '../i18n-no-flanking-whitespace';
|
|
10
|
+
|
|
11
|
+
const ruleTester = new RuleTester( {
|
|
12
|
+
parserOptions: {
|
|
13
|
+
ecmaVersion: 6,
|
|
14
|
+
},
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
ruleTester.run( 'i18n-no-flanking-whitespace', rule, {
|
|
18
|
+
valid: [
|
|
19
|
+
{
|
|
20
|
+
code: `__( 'Hello World…' )`,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
code:
|
|
24
|
+
'__( `A long string ` +\n `spread over ` +\n `multiple lines.` );',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
code: `__( 'Not concerned about \t whitespace rules')`,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
invalid: [
|
|
31
|
+
{
|
|
32
|
+
code: '__( "Double quoted string with a trailing newline\\n" );',
|
|
33
|
+
output: `__( 'Double quoted string with a trailing newline' );`,
|
|
34
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
code: `__( ' Leading whitespace.' );`,
|
|
38
|
+
output: `__( 'Leading whitespace.' );`,
|
|
39
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
code: `__( 'Trailing whitespace. ' );`,
|
|
43
|
+
output: `__( 'Trailing whitespace.' );`,
|
|
44
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
code: `__( ' Flanking whitespace. ' );`,
|
|
48
|
+
output: `__( 'Flanking whitespace.' );`,
|
|
49
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
code: '__( "\tLeading tab." );',
|
|
53
|
+
output: `__( 'Leading tab.' );`,
|
|
54
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
code: '__( "\u0009Leading unicode tab." );',
|
|
58
|
+
output: `__( 'Leading unicode tab.' );`,
|
|
59
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
code: `__( "Trailing tab.\t" );`,
|
|
63
|
+
output: `__( 'Trailing tab.' );`,
|
|
64
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
code: `__( "\tFlanking tab.\t" );`,
|
|
68
|
+
output: `__( 'Flanking tab.' );`,
|
|
69
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
{
|
|
73
|
+
code: '__( ` Template literals ` )',
|
|
74
|
+
errors: [ { messageId: 'noFlankingWhitespace' } ],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
} );
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RuleTester } from 'eslint';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import rule from '../is-gutenberg-plugin';
|
|
10
|
+
|
|
11
|
+
const ruleTester = new RuleTester( {
|
|
12
|
+
parserOptions: {
|
|
13
|
+
ecmaVersion: 6,
|
|
14
|
+
},
|
|
15
|
+
} );
|
|
16
|
+
|
|
17
|
+
const ERROR_MESSAGE =
|
|
18
|
+
'The `process.env.IS_GUTENBERG_PLUGIN` constant should only be used as the condition in an if statement or ternary expression.';
|
|
19
|
+
|
|
20
|
+
ruleTester.run( 'is-gutenberg-plugin', rule, {
|
|
21
|
+
valid: [
|
|
22
|
+
{ code: `if ( process.env.IS_GUTENBERG_PLUGIN ) {}` },
|
|
23
|
+
{ code: `if ( ! process.env.IS_GUTENBERG_PLUGIN ) {}` },
|
|
24
|
+
{
|
|
25
|
+
// Ensure whitespace is ok.
|
|
26
|
+
code: `if (
|
|
27
|
+
process.env.
|
|
28
|
+
IS_GUTENBERG_PLUGIN
|
|
29
|
+
) {}`,
|
|
30
|
+
},
|
|
31
|
+
{ code: `const test = process.env.IS_GUTENBERG_PLUGIN ? foo : bar` },
|
|
32
|
+
{ code: `const test = ! process.env.IS_GUTENBERG_PLUGIN ? bar : foo` },
|
|
33
|
+
{
|
|
34
|
+
// Ensure whitespace is ok.
|
|
35
|
+
code: `const test = ! process.env.
|
|
36
|
+
IS_GUTENBERG_PLUGIN ? bar : foo`,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
invalid: [
|
|
40
|
+
{
|
|
41
|
+
code: `if ( IS_GUTENBERG_PLUGIN ) {}`,
|
|
42
|
+
errors: [ { message: ERROR_MESSAGE } ],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
code: `if ( window[ 'IS_GUTENBERG_PLUGIN' ] ) {}`,
|
|
46
|
+
errors: [ { message: ERROR_MESSAGE } ],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
code: `if ( true ) { process.env.IS_GUTENBERG_PLUGIN === 2 }`,
|
|
50
|
+
errors: [ { message: ERROR_MESSAGE } ],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
code: `if ( process.env.IS_GUTENBERG_PLUGIN === 2 ) {}`,
|
|
54
|
+
errors: [ { message: ERROR_MESSAGE } ],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
code: `if ( true || process.env.IS_GUTENBERG_PLUGIN === 2 ) {}`,
|
|
58
|
+
errors: [ { message: ERROR_MESSAGE } ],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
code: `const isFeatureActive = process.env.IS_GUTENBERG_PLUGIN;`,
|
|
62
|
+
errors: [ { message: ERROR_MESSAGE } ],
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
} );
|
|
@@ -198,6 +198,7 @@ function getFixes( fixer, context, callNode ) {
|
|
|
198
198
|
module.exports = {
|
|
199
199
|
meta: {
|
|
200
200
|
type: 'problem',
|
|
201
|
+
hasSuggestions: true,
|
|
201
202
|
schema: [],
|
|
202
203
|
messages: {
|
|
203
204
|
doNotUseStringLiteral: `Do not use string literals ( '{{ argument }}' ) for accessing @wordpress/data stores. Pass the store definition instead`,
|
package/rules/gutenberg-phase.js
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
const {
|
|
5
|
+
TRANSLATION_FUNCTIONS,
|
|
6
|
+
getTextContentFromNode,
|
|
7
|
+
getTranslateFunctionName,
|
|
8
|
+
getTranslateFunctionArgs,
|
|
9
|
+
} = require( '../utils' );
|
|
10
|
+
|
|
11
|
+
const EN_DASH = '–';
|
|
12
|
+
const HYPHEN_IN_RANGE = /(\d\s+-\s+\d)|(\d-\d)/g;
|
|
13
|
+
|
|
14
|
+
function replaceHyphenWithEnDash( string ) {
|
|
15
|
+
if ( string.match( HYPHEN_IN_RANGE ) ) {
|
|
16
|
+
return string.replace( '-', EN_DASH );
|
|
17
|
+
}
|
|
18
|
+
return string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function makeFixerFunction( arg ) {
|
|
22
|
+
return ( fixer ) => {
|
|
23
|
+
switch ( arg.type ) {
|
|
24
|
+
case 'TemplateLiteral':
|
|
25
|
+
return arg.quasis.reduce( ( fixes, quasi ) => {
|
|
26
|
+
if (
|
|
27
|
+
'TemplateElement' === quasi.type &&
|
|
28
|
+
quasi.value.raw.match( HYPHEN_IN_RANGE )
|
|
29
|
+
) {
|
|
30
|
+
fixes.push(
|
|
31
|
+
fixer.replaceTextRange(
|
|
32
|
+
[ quasi.start, quasi.end ],
|
|
33
|
+
replaceHyphenWithEnDash( quasi.value.raw )
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return fixes;
|
|
38
|
+
}, [] );
|
|
39
|
+
|
|
40
|
+
case 'Literal':
|
|
41
|
+
return [
|
|
42
|
+
fixer.replaceText(
|
|
43
|
+
arg,
|
|
44
|
+
replaceHyphenWithEnDash( arg.raw )
|
|
45
|
+
),
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
case 'BinaryExpression':
|
|
49
|
+
return [
|
|
50
|
+
...makeFixerFunction( arg.left )( fixer ),
|
|
51
|
+
...makeFixerFunction( arg.right )( fixer ),
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
meta: {
|
|
59
|
+
type: 'problem',
|
|
60
|
+
schema: [],
|
|
61
|
+
messages: {
|
|
62
|
+
foundHyphen:
|
|
63
|
+
'Use dashes (en or em) in place of hyphens for numeric ranges.',
|
|
64
|
+
},
|
|
65
|
+
fixable: 'code',
|
|
66
|
+
},
|
|
67
|
+
create( context ) {
|
|
68
|
+
return {
|
|
69
|
+
CallExpression( node ) {
|
|
70
|
+
const { callee, arguments: args } = node;
|
|
71
|
+
|
|
72
|
+
const functionName = getTranslateFunctionName( callee );
|
|
73
|
+
|
|
74
|
+
if ( ! TRANSLATION_FUNCTIONS.has( functionName ) ) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const candidates = getTranslateFunctionArgs(
|
|
79
|
+
functionName,
|
|
80
|
+
args
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
for ( const arg of candidates ) {
|
|
84
|
+
const argumentString = getTextContentFromNode( arg );
|
|
85
|
+
if (
|
|
86
|
+
! argumentString ||
|
|
87
|
+
! argumentString.match( HYPHEN_IN_RANGE )
|
|
88
|
+
) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
context.report( {
|
|
93
|
+
node,
|
|
94
|
+
messageId: 'foundHyphen',
|
|
95
|
+
fix: makeFixerFunction( arg ),
|
|
96
|
+
} );
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
const {
|
|
5
|
+
TRANSLATION_FUNCTIONS,
|
|
6
|
+
getTextContentFromNode,
|
|
7
|
+
getTranslateFunctionName,
|
|
8
|
+
getTranslateFunctionArgs,
|
|
9
|
+
} = require( '../utils' );
|
|
10
|
+
|
|
11
|
+
const PROBLEMS_BY_CHAR_CODE = {
|
|
12
|
+
9: '\\t',
|
|
13
|
+
10: '\\n',
|
|
14
|
+
13: '\\r',
|
|
15
|
+
32: 'whitespace',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function makeFixerFunction( arg ) {
|
|
19
|
+
return ( fixer ) => {
|
|
20
|
+
switch ( arg.type ) {
|
|
21
|
+
case 'Literal':
|
|
22
|
+
return [ fixer.replaceText( arg, `'${ arg.value.trim() }'` ) ];
|
|
23
|
+
|
|
24
|
+
case 'BinaryExpression':
|
|
25
|
+
return [
|
|
26
|
+
...makeFixerFunction( arg.left )( fixer ),
|
|
27
|
+
...makeFixerFunction( arg.right )( fixer ),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
meta: {
|
|
35
|
+
type: 'problem',
|
|
36
|
+
schema: [],
|
|
37
|
+
messages: {
|
|
38
|
+
noFlankingWhitespace:
|
|
39
|
+
'Translations should not contain flanking whitespace{{problem}}',
|
|
40
|
+
},
|
|
41
|
+
fixable: 'code',
|
|
42
|
+
},
|
|
43
|
+
create( context ) {
|
|
44
|
+
return {
|
|
45
|
+
CallExpression( node ) {
|
|
46
|
+
const { callee, arguments: args } = node;
|
|
47
|
+
|
|
48
|
+
const functionName = getTranslateFunctionName( callee );
|
|
49
|
+
|
|
50
|
+
if ( ! TRANSLATION_FUNCTIONS.has( functionName ) ) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const candidates = getTranslateFunctionArgs(
|
|
55
|
+
functionName,
|
|
56
|
+
args
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
for ( const arg of candidates ) {
|
|
60
|
+
const argumentString = getTextContentFromNode( arg );
|
|
61
|
+
if ( ! argumentString ) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const trimmableWhitespace = argumentString.match(
|
|
66
|
+
/^\s|\s$/
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if ( ! trimmableWhitespace ) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const problem =
|
|
74
|
+
PROBLEMS_BY_CHAR_CODE[
|
|
75
|
+
trimmableWhitespace[ 0 ].charCodeAt( 0 )
|
|
76
|
+
];
|
|
77
|
+
const problemString = problem ? ` (${ problem })` : '';
|
|
78
|
+
|
|
79
|
+
context.report( {
|
|
80
|
+
node,
|
|
81
|
+
messageId: 'noFlankingWhitespace',
|
|
82
|
+
data: {
|
|
83
|
+
problem: problemString,
|
|
84
|
+
},
|
|
85
|
+
fix: makeFixerFunction( arg ),
|
|
86
|
+
} );
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Traverse up through the chain of parent AST nodes returning the first parent
|
|
3
|
+
* the predicate returns a truthy value for.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} sourceNode The AST node to search from.
|
|
6
|
+
* @param {Function} predicate A predicate invoked for each parent.
|
|
7
|
+
*
|
|
8
|
+
* @return {?Object } The first encountered parent node where the predicate
|
|
9
|
+
* returns a truthy value.
|
|
10
|
+
*/
|
|
11
|
+
function findParent( sourceNode, predicate ) {
|
|
12
|
+
if ( ! sourceNode.parent ) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if ( predicate( sourceNode.parent ) ) {
|
|
17
|
+
return sourceNode.parent;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return findParent( sourceNode.parent, predicate );
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Tests whether the IS_GUTENBERG_PLUGIN variable is used as the condition for an
|
|
25
|
+
* if statement or ternary, triggering a violation if not.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```js
|
|
29
|
+
* // good
|
|
30
|
+
* if ( process.env.IS_GUTENBERG_PLUGIN ) {
|
|
31
|
+
*
|
|
32
|
+
* // bad
|
|
33
|
+
* const isFeatureActive = process.env.IS_GUTENBERG_PLUGIN;
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} node The IS_GUTENBERG_PLUGIN identifier node.
|
|
37
|
+
* @param {Object} context The eslint context object.
|
|
38
|
+
*/
|
|
39
|
+
function isUsedInConditional( node, context ) {
|
|
40
|
+
const conditionalParent = findParent( node, ( candidate ) =>
|
|
41
|
+
[ 'IfStatement', 'ConditionalExpression' ].includes( candidate.type )
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if ( ! conditionalParent ) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Allow for whitespace as prettier sometimes breaks this on separate lines.
|
|
49
|
+
const textRegex = /^\s*!?\s*process\s*\.\s*env\s*\.\s*IS_GUTENBERG_PLUGIN$/;
|
|
50
|
+
const testSource = context.getSource( conditionalParent.test );
|
|
51
|
+
|
|
52
|
+
if ( ! textRegex.test( testSource ) ) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const ERROR_MESSAGE =
|
|
60
|
+
'The `process.env.IS_GUTENBERG_PLUGIN` constant should only be used as the condition in an if statement or ternary expression.';
|
|
61
|
+
|
|
62
|
+
module.exports = {
|
|
63
|
+
meta: {
|
|
64
|
+
type: 'problem',
|
|
65
|
+
schema: [],
|
|
66
|
+
},
|
|
67
|
+
create( context ) {
|
|
68
|
+
return {
|
|
69
|
+
Identifier( node ) {
|
|
70
|
+
// Bypass any identifiers with a node name different to `IS_GUTENBERG_PLUGIN`.
|
|
71
|
+
if ( node.name !== 'IS_GUTENBERG_PLUGIN' ) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if ( ! isUsedInConditional( node, context ) ) {
|
|
76
|
+
context.report( node, ERROR_MESSAGE );
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
// Check for literals, e.g. when 'IS_GUTENBERG_PLUGIN' is used as a string via something like 'window[ 'IS_GUTENBERG_PLUGIN' ]'.
|
|
80
|
+
Literal( node ) {
|
|
81
|
+
// Bypass any identifiers with a node value different to `IS_GUTENBERG_PLUGIN`.
|
|
82
|
+
if ( node.value !== 'IS_GUTENBERG_PLUGIN' ) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ( node.parent && node.parent.type === 'MemberExpression' ) {
|
|
87
|
+
if ( ! isUsedInConditional( node, context ) ) {
|
|
88
|
+
context.report( node, ERROR_MESSAGE );
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { RuleTester } from 'eslint';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import rule from '../gutenberg-phase';
|
|
10
|
-
|
|
11
|
-
const ruleTester = new RuleTester( {
|
|
12
|
-
parserOptions: {
|
|
13
|
-
ecmaVersion: 6,
|
|
14
|
-
},
|
|
15
|
-
} );
|
|
16
|
-
|
|
17
|
-
const ACCESS_ERROR =
|
|
18
|
-
'The `GUTENBERG_PHASE` constant should be accessed using `process.env.GUTENBERG_PHASE`.';
|
|
19
|
-
const EQUALITY_ERROR =
|
|
20
|
-
'The `GUTENBERG_PHASE` constant should only be used in a strict equality comparison with a primitive number.';
|
|
21
|
-
const IF_ERROR =
|
|
22
|
-
'The `GUTENBERG_PHASE` constant should only be used as part of the condition in an if statement or ternary expression.';
|
|
23
|
-
|
|
24
|
-
ruleTester.run( 'gutenberg-phase', rule, {
|
|
25
|
-
valid: [
|
|
26
|
-
{ code: `if ( process.env.GUTENBERG_PHASE === 2 ) {}` },
|
|
27
|
-
{ code: `if ( process.env.GUTENBERG_PHASE !== 2 ) {}` },
|
|
28
|
-
{ code: `if ( 2 === process.env.GUTENBERG_PHASE ) {}` },
|
|
29
|
-
{ code: `if ( 2 !== process.env.GUTENBERG_PHASE ) {}` },
|
|
30
|
-
{ code: `const test = process.env.GUTENBERG_PHASE === 2 ? foo : bar` },
|
|
31
|
-
{ code: `const test = process.env.GUTENBERG_PHASE !== 2 ? foo : bar` },
|
|
32
|
-
],
|
|
33
|
-
invalid: [
|
|
34
|
-
{
|
|
35
|
-
code: `if ( GUTENBERG_PHASE === 1 ) {}`,
|
|
36
|
-
errors: [ { message: ACCESS_ERROR } ],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
code: `if ( window[ 'GUTENBERG_PHASE' ] === 1 ) {}`,
|
|
40
|
-
errors: [ { message: ACCESS_ERROR } ],
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
code: `if ( process.env.GUTENBERG_PHASE > 1 ) {}`,
|
|
44
|
-
errors: [ { message: EQUALITY_ERROR } ],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
code: `if ( process.env.GUTENBERG_PHASE === '2' ) {}`,
|
|
48
|
-
errors: [ { message: EQUALITY_ERROR } ],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
code: `if ( true ) { process.env.GUTENBERG_PHASE === 2 }`,
|
|
52
|
-
errors: [ { message: IF_ERROR } ],
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
code: `if ( true || process.env.GUTENBERG_PHASE === 2 ) {}`,
|
|
56
|
-
errors: [ { message: IF_ERROR } ],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
code: `const isFeatureActive = process.env.GUTENBERG_PHASE === 2;`,
|
|
60
|
-
errors: [ { message: IF_ERROR } ],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
} );
|