Git Product home page Git Product logo

reserved-words's Introduction

reserved-words

Build Status

What is it?

Tiny package for detecting reserved words.

Reserved Word is either a Keyword, or a Future Reserved Word, or a Null Literal, or a Boolean Literal. See: ES5 #7.6.1 and ES6 #11.6.2.

Installation

npm install reserved-words

API

check(word, [dialect], [strict])

Returns true if provided identifier string is a Reserved Word in some ECMAScript dialect (ECMA-262 edition).

If the strict flag is truthy, this function additionally checks whether word is a Keyword or Future Reserved Word under strict mode.

Example

var reserved = require('reserved-words');
reserved.check('volatile', 'es3'); // true
reserved.check('volatile', 'es2015'); // false
reserved.check('yield', 3); // false
reserved.check('yield', 6); // true

dialects

es3 (or 3)

Represents ECMA-262 3rd edition.

See section 7.5.1.

es5 (or 5)

Represents ECMA-262 5th edition (ECMAScript 5.1).

Reserved Words are formally defined in ECMA262 sections 7.6.1.1 and 7.6.1.2.

es2015 (or es6, 6)

Represents [ECMA-262 6th edition](ECMAScript 2015).

Reserved Words are formally defined in sections 11.6.2.1 and 11.6.2.2.

License

Licensed under The MIT License

reserved-words's People

Contributors

chriswong avatar qfox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

reserved-words's Issues

Add `package` to reserved list?

Thanks for such a useful module!

Iโ€™m using it in a build script that transforms icon files into reusable JS components. Sometimes the file is named delete.png or whatever. I'm seeing this error in the build process now:

./components/icons.js
Syntax error: package is a reserved word in strict mode (64:7)

  62 | import newWindow from "../../../images/icons/output/new-window.png";
  63 | import onesie from "../../../images/icons/output/onesie.png";
> 64 | import package from "../../../images/icons/output/package.png";
     |        ^
  65 | import pharmacyPin from "../../../images/icons/output/pharmacy-pin.png";
  66 | import pharmacy from "../../../images/icons/output/pharmacy.png";
  67 | import photo from "../../../images/icons/output/photo.png";

 FAIL  Failed to compile

package is a future reserved word in "strict" mode according to the spec.

Are you open to a PR?

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.