Repository: tailwindlabs/tailwindcss
File: packages/@tailwindcss-upgrade/src/template/codemods/important.ts (TypeScript)

Code before:
    if (candidate.important && candidate.raw[candidate.raw.length - 1] !== '!') {
      // The important migration is one of the most broad migrations with a high
      // potential of matching false positives since `!` is a valid character in
      // most programming languages. Since v4 is technically backward compatible
      // with v3 in that it can read `!` in the front of the utility too, we err
      // on the side of caution and only migrate candidates that we are certain
      // are inside of a string.
      if (location) {
        let currentLineBeforeCandidate = ''
        for (let i = location.start - 1; i >= 0; i--) {
          let char = location.contents.at(i)!
          if (char === '\n') {
            break
          }
          currentLineBeforeCandidate = char + currentLineBeforeCandidate
        }
        let currentLineAfterCandidate = ''
        for (let i = location.end; i < location.contents.length; i++) {
          let char = location.contents.at(i)!
          if (char === '\n') {
            break
          }
          currentLineAfterCandidate += char
        }

        // Heuristics 1: Require the candidate to be inside quotes
        let isQuoteBeforeCandidate = QUOTES.some((quote) =>
          currentLineBeforeCandidate.includes(quote),
        )
        let isQuoteAfterCandidate = QUOTES.some((quote) =>
          currentLineAfterCandidate.includes(quote),
        )
        if (!isQuoteBeforeCandidate || !isQuoteAfterCandidate) {
          continue nextCandidate
        }

        // Heuristics 2: Disallow object access immediately following the candidate
        if (currentLineAfterCandidate[0] === '.') {
          continue nextCandidate
        }

        // Heuristics 3: Disallow logical operators proceeding or following the candidate
        for (let operator of LOGICAL_OPERATORS) {
          if (
            currentLineAfterCandidate.trim().startsWith(operator) ||
            currentLineBeforeCandidate.trim().endsWith(operator)
          ) {
            continue nextCandidate
          }
        }


Review comment (suggestion):
```suggestion
        // Heuristic 1: Require the candidate to be inside quotes
```

Code after:
  nextCandidate: for (let candidate of parseCandidate(rawCandidate, designSystem)) {
    if (candidate.important && candidate.raw[candidate.raw.length - 1] !== '!') {
      // The important migration is one of the most broad migrations with a high
      // potential of matching false positives since `!` is a valid character in
      // most programming languages. Since v4 is technically backward compatible
      // with v3 in that it can read `!` in the front of the utility too, we err
      // on the side of caution and only migrate candidates that we are certain
      // are inside of a string.
      if (location) {
        let currentLineBeforeCandidate = ''
        for (let i = location.start - 1; i >= 0; i--) {
          let char = location.contents.at(i)!
          if (char === '\n') {
            break
          }
          currentLineBeforeCandidate = char + currentLineBeforeCandidate
        }
        let currentLineAfterCandidate = ''
        for (let i = location.end; i < location.contents.length; i++) {
          let char = location.contents.at(i)!
          if (char === '\n') {
            break
          }
          currentLineAfterCandidate += char
        }

        // Heuristic 1: Require the candidate to be inside quotes
        let isQuoteBeforeCandidate = QUOTES.some((quote) =>
          currentLineBeforeCandidate.includes(quote),
        )
        let isQuoteAfterCandidate = QUOTES.some((quote) =>
          currentLineAfterCandidate.includes(quote),
        )
        if (!isQuoteBeforeCandidate || !isQuoteAfterCandidate) {
          continue nextCandidate
        }

        // Heuristic 2: Disallow object access immediately following the candidate
        if (currentLineAfterCandidate[0] === '.') {
          continue nextCandidate
        }

        // Heuristic 3: Disallow logical operators preceding or following the candidate
        for (let operator of LOGICAL_OPERATORS) {
          if (
            currentLineAfterCandidate.trim().startsWith(operator) ||
            currentLineBeforeCandidate.trim().endsWith(operator)
          ) {
            continue nextCandidate
          }
        }