Skip to content

always set markers for spaced-comment rule to support reference types #318

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ module.exports = {
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/array-type": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔If you're interested in enabling another rule, would you mind filing a separate issue/PR? I'm generally in favor of this change but it'd be good to keep it separate.

"error",
{
default: "array-simple",
readonly: "array-simple",
},
],
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/generic-type-naming": "off",
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
*.map
coverage/
node_modules/
pnpm-lock.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with these: +1 to including this in a separate issue and/or PR?

Guessing you're a happy pnpm user? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, shall we put this and array-type settings separately?

src/**/*.js
test/*.js
~test/jest.config.js
!test/tests/**/.eslintrc*
!test/tests/**/*.log
.idea/
7 changes: 4 additions & 3 deletions src/rules/converters/comment-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export const CapitalizedIgnoreMessage = "Only accepts a single string pattern to

export const convertCommentFormat: RuleConverter = tslintRule => {
const capitalizedRuleArguments: string[] = [];
const spaceCommentRuleArguments: string[] = [];
const spaceCommentRuleArguments: Array<string | { markers: string[] }> = [];
const capitalizedNotices: string[] = [];

if (!tslintRule.ruleArguments.includes("check-space")) {
spaceCommentRuleArguments.push("never");
if (!spaceCommentRuleArguments.includes("always")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, looks like you're missing unit test coverage for this line per the test coverage report. You'll need to add test coverage for this case to get it to pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point, will made another update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I do not know how. I tried to duplicate the test case on line 19, added another version without the check-space in ruleArguments array, but npm run test:ci still complain missing coverage on that line

https://github.com/typescript-eslint/tslint-to-eslint-config/pull/318/files/e51155daa587e4f8d6f54f145c85d76ab7c74ea4#diff-e32ee4f42ec93518baf8586b4fb733caL19

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem on line 15 is that spaceCommentRuleArguments is an empty array so the test suite is not satisfying the condition. Also, shouldn't it be tslintRule.ruleArguments as before?

spaceCommentRuleArguments.push("always");
}
spaceCommentRuleArguments.push({ markers: ["/"] });

if (tslintRule.ruleArguments.includes("check-uppercase")) {
capitalizedRuleArguments.push("always");
Expand Down
18 changes: 10 additions & 8 deletions src/rules/converters/tests/comment-format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe(convertCommentFormat, () => {
expect(result).toEqual({
rules: [
{
ruleArguments: ["never"],
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -24,6 +24,7 @@ describe(convertCommentFormat, () => {
expect(result).toEqual({
rules: [
{
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -42,7 +43,7 @@ describe(convertCommentFormat, () => {
ruleName: "capitalized-comments",
},
{
ruleArguments: ["never"],
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -62,7 +63,7 @@ describe(convertCommentFormat, () => {
ruleName: "capitalized-comments",
},
{
ruleArguments: ["never"],
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -77,7 +78,7 @@ describe(convertCommentFormat, () => {
expect(result).toEqual({
rules: [
{
ruleArguments: ["never"],
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -96,7 +97,7 @@ describe(convertCommentFormat, () => {
ruleName: "capitalized-comments",
},
{
ruleArguments: ["never"],
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -111,7 +112,7 @@ describe(convertCommentFormat, () => {
expect(result).toEqual({
rules: [
{
ruleArguments: ["never"],
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -131,7 +132,7 @@ describe(convertCommentFormat, () => {
ruleName: "capitalized-comments",
},
{
ruleArguments: ["never"],
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -146,7 +147,7 @@ describe(convertCommentFormat, () => {
expect(result).toEqual({
rules: [
{
ruleArguments: ["never"],
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand All @@ -172,6 +173,7 @@ describe(convertCommentFormat, () => {
ruleName: "capitalized-comments",
},
{
ruleArguments: ["always", { markers: ["/"] }],
ruleName: "spaced-comment",
},
],
Expand Down