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 misspelled whitespace #817

Merged
merged 4 commits into from
Sep 1, 2020
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
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"eslint-template-visitor": "^2.2.1",
"eslint-utils": "^2.1.0",
"import-modules": "^2.0.0",
"lodash": "^4.17.15",
"lodash": "^4.17.20",
"pluralize": "^8.0.0",
"read-pkg-up": "^7.0.1",
"regexp-tree": "^0.1.21",
Expand All @@ -49,26 +49,26 @@
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"@babel/code-frame": "7.10.3",
"@babel/code-frame": "7.10.4",
"@lubien/fixture-beta-package": "^1.0.0-beta.1",
"@typescript-eslint/parser": "^3.4.0",
"ava": "^3.9.0",
"@typescript-eslint/parser": "^4.0.1",
"ava": "^3.12.1",
"babel-eslint": "^10.1.0",
"chalk": "^4.1.0",
"eslint": "^7.3.0",
"eslint": "^7.8.0",
"eslint-ava-rule-tester": "^4.0.0",
"eslint-plugin-eslint-plugin": "^2.3.0",
"execa": "^4.0.2",
"execa": "^4.0.3",
"listr": "^0.14.3",
"nyc": "^15.1.0",
"outdent": "^0.7.1",
"pify": "^5.0.0",
"typescript": "^3.9.5",
"typescript": "^4.0.2",
"vue-eslint-parser": "^7.1.0",
"xo": "^0.32.0"
"xo": "^0.33.1"
},
"peerDependencies": {
"eslint": ">=7.3.0"
"eslint": ">=7.8.0"
},
"ava": {
"babel": true,
Expand Down
14 changes: 7 additions & 7 deletions rules/expiring-todo-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MESSAGE_ID_HAVE_PACKAGE = 'unicorn/havePackage';
const MESSAGE_ID_DONT_HAVE_PACKAGE = 'unicorn/dontHavePackage';
const MESSAGE_ID_VERSION_MATCHES = 'unicorn/versionMatches';
const MESSAGE_ID_ENGINE_MATCHES = 'unicorn/engineMatches';
const MESSAGE_ID_REMOVE_WHITESPACES = 'unicorn/removeWhitespaces';
const MESSAGE_ID_REMOVE_WHITESPACE = 'unicorn/removeWhitespaces';
const MESSAGE_ID_MISSING_AT_SYMBOL = 'unicorn/missingAtSymbol';

const packageResult = readPkgUp.sync();
Expand Down Expand Up @@ -448,16 +448,16 @@ const create = context => {
}
}

const withoutWhitespaces = unknown.replace(/ /g, '');
const withoutWhitespace = unknown.replace(/ /g, '');

if (parseArgument(withoutWhitespaces).type !== 'unknowns') {
if (parseArgument(withoutWhitespace).type !== 'unknowns') {
uses++;
context.report({
loc: comment.loc,
messageId: MESSAGE_ID_REMOVE_WHITESPACES,
messageId: MESSAGE_ID_REMOVE_WHITESPACE,
data: {
original: unknown,
fix: withoutWhitespaces,
fix: withoutWhitespace,
message: parseTodoMessage(comment.value)
}
});
Expand Down Expand Up @@ -526,8 +526,8 @@ module.exports = {
'There is a TODO match for package version: {{comparison}}. {{message}}',
[MESSAGE_ID_ENGINE_MATCHES]:
'There is a TODO match for Node.js version: {{comparison}}. {{message}}',
[MESSAGE_ID_REMOVE_WHITESPACES]:
'Avoid using whitespaces on TODO argument. On \'{{original}}\' use \'{{fix}}\'. {{message}}',
[MESSAGE_ID_REMOVE_WHITESPACE]:
'Avoid using whitespace on TODO argument. On \'{{original}}\' use \'{{fix}}\'. {{message}}',
[MESSAGE_ID_MISSING_AT_SYMBOL]:
'Missing \'@\' on TODO argument. On \'{{original}}\' use \'{{fix}}\'. {{message}}',
...baseRule.meta.messages
Expand Down
64 changes: 32 additions & 32 deletions test/expiring-todo-comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ const avoidMultiplePackageVersionsError = (versions, message) => ({
message: `Avoid using multiple package versions in TODO: ${versions}. ${message}`
});

const removeWhitespacesError = (argument, message) => ({
message: `Avoid using whitespaces on TODO argument. On '${argument}' use '${argument.replace(/ /g, '')}'. ${message}`
const removeWhitespaceError = (argument, message) => ({
message: `Avoid using whitespace on TODO argument. On '${argument}' use '${argument.replace(/ /g, '')}'. ${message}`
});

const missingAtSymbolError = (bad, good, message) => ({
message: `Missing '@' on TODO argument. On '${bad}' use '${good}'. ${message}`
});

const noWarningCommentError = () => ({
message: 'Unexpected \'todo\' comment.'
const noWarningCommentError = comment => ({
message: `Unexpected 'todo' comment: '${comment}'.`
});

ruleTester.run('expiring-todo-comments', rule, {
Expand Down Expand Up @@ -248,66 +248,66 @@ ruleTester.run('expiring-todo-comments', rule, {
errors: [missingAtSymbolError('semver>1', 'semver@>1', 'Missing @.')]
},
{
code: '// TODO [> 1]: Remove whitespaces when it can fix.',
errors: [removeWhitespacesError('> 1', 'Remove whitespaces when it can fix.')]
code: '// TODO [> 1]: Remove whitespace when it can fix.',
errors: [removeWhitespaceError('> 1', 'Remove whitespace when it can fix.')]
},
{
code: '// TODO [semver@> 1]: Remove whitespaces when it can fix.',
errors: [removeWhitespacesError('semver@> 1', 'Remove whitespaces when it can fix.')]
code: '// TODO [semver@> 1]: Remove whitespace when it can fix.',
errors: [removeWhitespaceError('semver@> 1', 'Remove whitespace when it can fix.')]
},
{
code: '// TODO [semver @>1]: Remove whitespaces when it can fix.',
errors: [removeWhitespacesError('semver @>1', 'Remove whitespaces when it can fix.')]
code: '// TODO [semver @>1]: Remove whitespace when it can fix.',
errors: [removeWhitespaceError('semver @>1', 'Remove whitespace when it can fix.')]
},
{
code: '// TODO [semver@>= 1]: Remove whitespaces when it can fix.',
errors: [removeWhitespacesError('semver@>= 1', 'Remove whitespaces when it can fix.')]
code: '// TODO [semver@>= 1]: Remove whitespace when it can fix.',
errors: [removeWhitespaceError('semver@>= 1', 'Remove whitespace when it can fix.')]
},
{
code: '// TODO [semver @>=1]: Remove whitespaces when it can fix.',
errors: [removeWhitespacesError('semver @>=1', 'Remove whitespaces when it can fix.')]
code: '// TODO [semver @>=1]: Remove whitespace when it can fix.',
errors: [removeWhitespaceError('semver @>=1', 'Remove whitespace when it can fix.')]
},
{
code: '// TODO [engine:node @>=1]: Remove whitespaces when it can fix.',
errors: [removeWhitespacesError('engine:node @>=1', 'Remove whitespaces when it can fix.')]
code: '// TODO [engine:node @>=1]: Remove whitespace when it can fix.',
errors: [removeWhitespaceError('engine:node @>=1', 'Remove whitespace when it can fix.')]
},
{
code: '// TODO [engine:node@>= 1]: Remove whitespaces when it can fix.',
errors: [removeWhitespacesError('engine:node@>= 1', 'Remove whitespaces when it can fix.')]
code: '// TODO [engine:node@>= 1]: Remove whitespace when it can fix.',
errors: [removeWhitespaceError('engine:node@>= 1', 'Remove whitespace when it can fix.')]
},
{
code: '// TODO',
errors: [noWarningCommentError()],
errors: [noWarningCommentError('TODO')],
options: [{allowWarningComments: false}]
},
{
code: '// TODO []',
errors: [noWarningCommentError()],
errors: [noWarningCommentError('TODO []')],
options: [{allowWarningComments: false}]
},
{
code: '// TODO [no meaning at all]',
errors: [noWarningCommentError()],
errors: [noWarningCommentError('TODO [no meaning at all]')],
options: [{allowWarningComments: false}]
},
{
code: '// TODO [] might have [some] that [try [to trick] me]',
errors: [noWarningCommentError()],
errors: [noWarningCommentError('TODO [] might have [some] that [try [to...')],
options: [{allowWarningComments: false}]
},
{
code: '// TODO [but [it will]] [fallback] [[[ to the default ]]] rule [[[',
errors: [noWarningCommentError()],
errors: [noWarningCommentError('TODO [but [it will]] [fallback] [[[ to...')],
options: [{allowWarningComments: false}]
},
{
code: '// TODO [engine:npm@>=10000]: Unsupported engine',
errors: [noWarningCommentError()],
errors: [noWarningCommentError('TODO [engine:npm@>=10000]: Unsupported...')],
options: [{allowWarningComments: false}]
},
{
code: '// TODO [engine:somethingrandom@>=10000]: Unsupported engine',
errors: [noWarningCommentError()],
errors: [noWarningCommentError('TODO [engine:somethingrandom@>=10000]:...')],
options: [{allowWarningComments: false}]
},
{
Expand Down Expand Up @@ -348,10 +348,10 @@ ruleTester.run('expiring-todo-comments', rule, {
options: [{ignoreDatesOnPullRequests: false, terms: ['Expire Condition']}]
},
{
code: '// TODO [semver @>=1, -popura]: Package uninstalled and whitespaces error',
code: '// TODO [semver @>=1, -popura]: Package uninstalled and whitespace error',
errors: [
dontHavePackageError('popura', 'Package uninstalled and whitespaces error'),
removeWhitespacesError('semver @>=1', 'Package uninstalled and whitespaces error')
dontHavePackageError('popura', 'Package uninstalled and whitespace error'),
removeWhitespaceError('semver @>=1', 'Package uninstalled and whitespace error')
]
},
{
Expand All @@ -363,15 +363,15 @@ ruleTester.run('expiring-todo-comments', rule, {
havePackageError('read-pkg-up', 'Big mix'),
versionMatchesError('read-pkg-up > 1', 'Big mix'),
engineMatchesError('node>=8', 'Big mix'),
removeWhitespacesError('semver @>=1', 'Big mix')
removeWhitespaceError('semver @>=1', 'Big mix')
],
options: [{ignoreDatesOnPullRequests: false, terms: ['HUGETODO']}]
},
{
code: '// TODO [ISSUE-123] fix later',
options: [{allowWarningComments: false, ignore: []}],
errors: [
noWarningCommentError()
noWarningCommentError('TODO [ISSUE-123] fix later')
]
},
{
Expand All @@ -381,7 +381,7 @@ ruleTester.run('expiring-todo-comments', rule, {
`,
options: [{allowWarningComments: false, ignore: [/issue-\d+/i]}],
errors: [
noWarningCommentError()
noWarningCommentError('TODO fix later')
]
},
{
Expand All @@ -391,7 +391,7 @@ ruleTester.run('expiring-todo-comments', rule, {
*/`,
options: [{allowWarningComments: false, ignore: [/issue-\d+/i]}],
errors: [
noWarningCommentError()
noWarningCommentError('TODO Invalid')
]
}
]
Expand Down
9 changes: 4 additions & 5 deletions test/integration/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ module.exports = [
'aio/content/examples/router/src/app/app-routing.module.9.ts'
]
},
// TODO: enable this when ``@typescript-eslint/parser` support typescript 4.0
// {
// repository: 'https://github.com/microsoft/typescript',
// extraArguments: typescriptArguments
// },
{
repository: 'https://github.com/microsoft/typescript',
extraArguments: typescriptArguments
},
{
repository: 'https://github.com/microsoft/vscode',
extraArguments: typescriptArguments
Expand Down