stryker-js icon indicating copy to clipboard operation
stryker-js copied to clipboard

disable next-line doesn't work with multi-line template literals

Open pmcelhaney opened this issue 3 years ago • 1 comments

Summary

In the below code I don't believe the ObjectLiteral mutation should have been created.

image

function renderTime(time: Temporal.PlainTime): Renderable {
  /* Stryker disable next-line StringLiteral, ObjectLiteral */
  return html`
    <time datetime=${time.toString(8{ smallestUnit: "minute" })}
      >${formatTime(time)}</time
    >
  `;
}

Stryker config

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "packageManager": "yarn",
  "reporters": ["html", "progress"],
  "htmlReporter": {
    "baseDir": "coverage/mutation/html"
  },
  "testRunner": "jest",
  "coverageAnalysis": "perTest",
  "mutate": [
    "packages/*/src/**/*.ts",
    "!packages/*/src/stories/**",
    "packages/eslint-plugin/lib/rules/*.js"
  ],
  "checkers": ["typescript"],
  "tsconfigFile": "tsconfig.json"
}

Test runner config

Stryker environment

├── @stryker-mutator/[email protected]
├── @stryker-mutator/[email protected]
├── @stryker-mutator/[email protected]
├── [email protected]

├── @stryker-mutator/[email protected]
├── @types/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]

Test runner environment

stryker run --mutate ./packages/consumer-app/src/elements/h3-docket.ts

I can add the Jest config if you insist, but I really don't think it's relevant in this case.

Your Environment

software version(s)
node v16.9.0
npm 7.21.1
Operating System macOS 11.6

stryker.log

pmcelhaney avatar Nov 15 '21 16:11 pmcelhaney

For now I'm working around it by disabling and then restoring the rule.

function renderTime(time: Temporal.PlainTime): Renderable {
  /* Stryker disable StringLiteral, ObjectLiteral */
  return html`
    <time datetime=${time.toString({ smallestUnit: "minute" })}
      >${formatTime(time)}</time
    >
  `;
  /* Stryker restore all */
}

pmcelhaney avatar Nov 15 '21 16:11 pmcelhaney

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 19 '22 18:11 stale[bot]