Skip to content

Commit

Permalink
Calypso linting: allow WordPress dependencies as import docblocks
Browse files Browse the repository at this point in the history
Fixes #44387
  • Loading branch information
jeherve committed Jul 23, 2020
1 parent 9159ff9 commit 3406ffa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-plugin-wpcalypso/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Then configure the rules you want to use under the rules section.
- [`i18n-no-variables`](docs/rules/i18n-no-variables.md): Disallow variables as translate strings
- [`jsx-classname-namespace`](docs/rules/jsx-classname-namespace.md): Ensure JSX className adheres to CSS namespace guidelines
- [`jsx-gridicon-size`](docs/rules/jsx-gridicon-size.md): Enforce recommended Gridicon size attributes
- [`import-docblock`](docs/rules/import-docblock.md): Enforce external, internal dependencies docblocks
- [`import-docblock`](docs/rules/import-docblock.md): Enforce external, internal, WordPress dependencies docblocks
- [`post-message-no-wildcard-targets`](docs/rules/post-message-no-wildcard-targets.md): Disallow using the wildcard '*' in `postMessage`
- [`redux-no-bound-selectors`](docs/rules/redux-no-bound-selectors.md): Disallow creation of selectors bound to Redux state

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Enforce external, internal dependencies docblocks
# Enforce external, internal, WordPress dependencies docblocks

When importing modules, you should distinguish external dependencies from internal dependencies using DocBlock multi-line comments. Because Calypso modifies the `NODE_PATH` to allow importing modules directly from the root `client/` directory, it can be otherwise unclear whether an imported module is an internal or an external dependency.
When importing modules, you should distinguish external dependencies from internal or WordPress dependencies using DocBlock multi-line comments. Because Calypso modifies the `NODE_PATH` to allow importing modules directly from the root `client/` directory, it can be otherwise unclear whether an imported module is an internal, external, or WordPress dependency.

## Rule Details

Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-plugin-wpcalypso/lib/rules/import-docblock.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file Enforce external, internal dependencies docblocks
* @file Enforce external, internal, WordPress dependencies docblocks
* @author Automattic
* @copyright 2016 Automattic. All rights reserved.
* See LICENSE.md file in root directory for full license.
Expand All @@ -9,13 +9,13 @@
// Rule Definition
//------------------------------------------------------------------------------

const ERROR_MESSAGE = 'Missing external, internal dependencies docblocks';
const RX_DOCBLOCK = /\/\*\*\n \* (Ex|In)ternal dependencies\s*\n \*\//i;
const ERROR_MESSAGE = 'Missing external, internal, WordPress dependencies docblocks';
const RX_DOCBLOCK = /\/\*\*\n \* ((Ex|In)ternal|WordPress) dependencies\s*\n \*\//i;

module.exports = {
meta: {
docs: {
description: 'Enforce external, internal dependencies docblocks',
description: 'Enforce external, internal, WordPress dependencies docblocks',
category: 'Stylistic Issues',
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file Enforce external, internal dependencies docblocks
* @file Enforce external, internal, WordPress dependencies docblocks
* @author Automattic
* @copyright 2016 Automattic. All rights reserved.
* See LICENSE.md file in root directory for full license.
Expand Down Expand Up @@ -27,19 +27,19 @@ new RuleTester( {
code: `/**
* External dependencies
*/
import eslint from \'eslint\';`,
import eslint from 'eslint';`,
},
{
code: `/**
* External dependencies
*/
import eslint from \'eslint\';`,
import eslint from 'eslint';`,
},
{
code: `/**
* External dependencies${ ' ' }
*/
import eslint from \'eslint\';`,
import eslint from 'eslint';`,
},
],

Expand All @@ -48,7 +48,7 @@ import eslint from \'eslint\';`,
code: "import eslint from 'eslint';",
errors: [
{
message: 'Missing external, internal dependencies docblocks',
message: 'Missing external, internal, WordPress dependencies docblocks',
},
],
},
Expand Down

0 comments on commit 3406ffa

Please sign in to comment.