JSPM

coffeelint-no-accessor-existential-operator

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q12362F
  • License MIT

CoffeeLint plugin for prohibiting accessor with existential operator.

Package Exports

  • coffeelint-no-accessor-existential-operator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (coffeelint-no-accessor-existential-operator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

coffeelint-no-accessor-existential-operator

CoffeeLint plugin for prohibiting accessor with existential operator.

When coffeescript transpile to ES2015(ES6) by transpiler(decaf, decaffeinate), accessor with existential operator is transpiled complex code.

Example:

# coffeescript sample using accessor with existential operator
hoge?.fuga?.piyo()

# transpiled JS by decaf
var ref;
typeof hoge !== "undefined" && hoge !== null ? ((ref = hoge.fuga) != null ? ref.piyo() : void 0) : void 0;

I recommend fix coffeescript before transpile.

Install

$ npm install --save-dev coffeelint-no-accessor-existential-operator

Usage

Put this in your coffeelint config

{
  "no_accessor_existential_operator": {
    "module": "coffeelint-no-accessor-existential-operator"
  }
}

Examples

# Bad
hoge?.fuga
doit() if hoge?.fuga?

# Good (Note that following code not equals completely)
hoge.fuga if hoge?
doit() if hoge && hoge.fuga?

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request