Skip to content
This repository has been archived by the owner on Sep 10, 2020. It is now read-only.

Babel plugin to make const declarations immutable

Notifications You must be signed in to change notification settings

spudly/babel-plugin-const-const

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@spudly/babel-plugin-const-const

A babel plugin that transforms all const declarations, wrapping the initilization expression with deepfreeze() to make it immutable (which is apparently what lots of people think const already does.

Disclaimer: This is almost certainly a terrible idea; I created this as a joke! That said, it does work so if you think it's useful, feel free to use it.

Example

Input:

let a = {
  a: 'A',
};

const b = {
  b: 'B',
};

Output:

import deepfreeze from 'deepfreeze';

let a = {
  a: 'A',
};

const b = deepfreeze({
  b: 'B',
});

Install

Using npm:

npm install --save-dev @spudly/babel-plugin-const-const

or using yarn:

yarn add @spudly/babel-plugin-const-const

About

Babel plugin to make const declarations immutable

Resources

Stars

Watchers

Forks

Packages

No packages published