Skip to content

Latest commit

 

History

History

replace-with-boolean-literal

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

replace-with-boolean-literal plugin

Replace given constants with boolean literals.

Setup

import { replaceWithBooleanLiteral } from '@tsm-cookbook/replace-with-boolean-literal'

export default defineConfig({
  plugins: [replaceWithBooleanLiteral({
    constants: {
      globalObject: {
        trueValue: true,
        falsyValue: false,
      }
    }
  })],
})

Example (LSP Runtime)

if (globalObject.trueValue) {
  console.log('true')
}

if (globalObject.falsyValue) {
  console.log('false')
}

To

if (true) {
  console.log('true')
}

if (false) {
  console.log('false')
}