Coder Social home page Coder Social logo

philippsoehnlein / esformatter-dot-notation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pgilad/esformatter-dot-notation

0.0 2.0 0.0 94 KB

esformatter plugin for transforming object bracket usage to dot notation

License: MIT License

JavaScript 100.00%

esformatter-dot-notation's Introduction

esformatter-dot-notation

esformatter plugin for transforming object bracket usage to dot notation

NPM Version NPM Downloads Build Status

esformatter-dot-notation is a plugin for esformatter meant to convert accessing object properties with brackets into dot notation where valid.

This module uses unquoted-property-validator which uses Mathias Bynens implementation in order to validate if a property name is a valid identifier name and can be used with dot notation.

That means invalid identifiers will not be converted and your code is safe for transformations (see tests).

Turn this:

someObject['property'] = true;

into:

someObject.property = true;

Installation

$ npm install esformatter-dot-notation --save-dev

Config

Newest esformatter versions autoload plugins from your node_modules See this

Add to your esformatter config file:

{
  "plugins": [
    "esformatter-dot-notation"
  ]
}

Or you can manually register your plugin:

var dotNotation = require('esformatter-dot-notation');
// register plugin
esformatter.register(dotNotation);

Usage

var fs = require('fs');
var esformatter = require('esformatter');
//register plugin manually
esformatter.register(require('esformatter-dot-notation'));

var str = fs.readFileSync('someKewlFile.js').toString();
var output = esformatter.format(str);
//-> output will now contain the formatted string

See esformatter for more options and further usage.

License

MIT @Gilad Peleg

esformatter-dot-notation's People

Contributors

pgilad avatar philippsoehnlein avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.