diff --git a/README.md b/README.md index b962d79..3e35a11 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ This ESLint plugin comes with multiple rules to help you apply some pattern on v ## Rules -- [Rules](#rules) - - [preferred-export-default-naming](#preferred-export-default-naming) - - [Configuration](#configuration) - - [Example](#example) - - [prevent-imports](#prevent-imports) - - [Configuration](#configuration-1) - - [Example](#example-1) +1. [Rules](#rules) + 1. [preferred-export-default-naming](#preferred-export-default-naming) + 1. [Configuration](#configuration) + 2. [Example](#example) + 2. [prevent-imports](#prevent-imports) + 1. [Configuration](#configuration-1) + 2. [Example](#example-1) ### preferred-export-default-naming @@ -100,7 +100,7 @@ This rule enforces a default name for export default & namespace. By default, de */ // ❌ -import { findDOMNode } from "react-dom"; // findDOMNode cannot be imported +import { findDOMNode } from "react-dom"; // findDOMNode shouldn’t be imported import * as ReactDOM from "react-dom"; ReactDOM.findDOMNode(); // ❌ It recognizes that findDOMNode is from react-dom @@ -123,14 +123,14 @@ You can specify a reason why multiple imports are forbidden: */ // ❌ -import type { FC } from "react"; // Error: `You cannot import "FC" from "react": Prefer React.VoidFunctionComponent` +import type { FC } from "react"; // Error: `You shouldn’t import "FC" from "react": Prefer React.VoidFunctionComponent` const MyComponent: FC = () => {}; import React from "react"; -const MyComponent: React.FunctionComponent = () => {}; // Error: `You cannot use "FunctionComponent" from "react": Prefer React.VoidFunctionComponent` +const MyComponent: React.FunctionComponent = () => {}; // Error: `You shouldn’t use "FunctionComponent" from "react": Prefer React.VoidFunctionComponent` import * as React from "react"; -const MyComponent: React.VFC = () => {}; // Error: `You cannot use "VFC" from "react": Prefer React.VoidFunctionComponent` +const MyComponent: React.VFC = () => {}; // Error: `You shouldn’t use "VFC" from "react": Prefer React.VoidFunctionComponent` // ✅ import * as React from "react"; diff --git a/src/prevent-imports.ts b/src/prevent-imports.ts index 1167280..08e903f 100644 --- a/src/prevent-imports.ts +++ b/src/prevent-imports.ts @@ -87,7 +87,7 @@ const rule: Rule.RuleModule = { continue; } - let message = `You cannot import "${matchedName}" from "${foundOption.module}"`; + let message = `You shouldn’t import "${matchedName}" from "${foundOption.module}"`; if (foundOption.reason) { message += `: ${foundOption.reason}`; } @@ -138,7 +138,7 @@ const rule: Rule.RuleModule = { ) { continue; } - let message = `You cannot use "${property}" from "${elementToCheck.module}"`; + let message = `You shouldn’t use "${property}" from "${elementToCheck.module}"`; if (elementToCheck.reason) { message += `: ${elementToCheck.reason}`; } diff --git a/tests/prevent-imports.ts b/tests/prevent-imports.ts index a8940b0..0a400b6 100644 --- a/tests/prevent-imports.ts +++ b/tests/prevent-imports.ts @@ -35,9 +35,9 @@ const suites: Array<{ }, ], errors: [ - 'You cannot import "a" from "b"', - 'You cannot use "d" from "c": Prefer f', - 'You cannot use "e" from "c": Prefer f', + 'You shouldn’t import "a" from "b"', + 'You shouldn’t use "d" from "c": Prefer f', + 'You shouldn’t use "e" from "c": Prefer f', ], }, @@ -57,10 +57,10 @@ const suites: Array<{ }, ], errors: [ - 'You cannot import "b" from "a": B', - 'You cannot import "c" from "a": C', - 'You cannot use "b" from "a": B', - 'You cannot use "c" from "a": C', + 'You shouldn’t import "b" from "a": B', + 'You shouldn’t import "c" from "a": C', + 'You shouldn’t use "b" from "a": B', + 'You shouldn’t use "c" from "a": C', ], }, ];