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

fix(eslint-plugin): ignore all whitespaces in comparison #4223

Merged
merged 1 commit into from Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/ban-types.ts
Expand Up @@ -25,7 +25,7 @@ export type Options = [
export type MessageIds = 'bannedTypeMessage';

function removeSpaces(str: string): string {
return str.replace(/ /g, '');
return str.replace(/\s/g, '');
}

function stringifyNode(
Expand Down
12 changes: 12 additions & 0 deletions packages/eslint-plugin/tests/rules/ban-types.test.ts
Expand Up @@ -394,10 +394,13 @@ let b: Foo<NS.Good>;
code: noFormat`
let foo: {} = {};
let bar: { } = {};
let baz: {
} = {};
`,
output: `
let foo: object = {};
let bar: object = {};
let baz: object = {};
`,
options: [
{
Expand Down Expand Up @@ -428,6 +431,15 @@ let bar: object = {};
line: 3,
column: 10,
},
{
messageId: 'bannedTypeMessage',
data: {
name: '{}',
customMessage: ' Use object instead.',
},
line: 4,
column: 10,
},
],
},
{
Expand Down