GithubHelp home page GithubHelp logo

dependents / node-ast-module-types Goto Github PK

View Code? Open in Web Editor NEW
11.0 11.0 3.0 795 KB

AST helpers for recognizing CommonJS, AMD, and ES6 module types

License: MIT License

JavaScript 100.00%
amd ast commonjs es6

node-ast-module-types's Issues

isDefineAMD fails when using arrow functions

Add the following test in test/tests.js. Run npm test and notice that fails:

assert.ok(check("define(['jquery'] , ($) => { class A {} return A;});", types.isDefineAMD));

Checkout version 2.7.0, which has commit hash of f5c2a2c. Execute the same test and notice that now it passes. This might be a regression of #18, although I'm not sure about it.

top-level "define" results in false positives for "amd" type

I think this issue belongs here, but might belong in module-definition.

I found a false positive with ansi-colors, which has a top-level define, but it (ahem) defines define itself. module-definition thinks this is an AMD module.

I'm not sure how this should be addressed. Should module-definition only consider a module to be AMD if define is used as a global? Or if define has a certain specific signature? Unsure if the change should live in module-definition or here or both.

If you can point me in the right direction, I may be able to send a PR to address it.

thanks!

Stronger isExports matching

Currently doesn't handle:

exports = function() {
}

The AST for that uses an AssignmentExpression:

{
    "type": "Program",
    "body": [
        {
            "type": "ExpressionStatement",
            "expression": {
                "type": "AssignmentExpression",
                "operator": "=",
                "left": {
                    "type": "Identifier",
                    "name": "exports"
                },
                "right": {
                    "type": "FunctionExpression",
                    "id": null,
                    "params": [],
                    "defaults": [],
                    "body": {
                        "type": "BlockStatement",
                        "body": []
                    },
                    "rest": null,
                    "generator": false,
                    "expression": false
                }
            }
        }
    ]
}

Possible false-positive?

A non-module JS file that has a define() signature nested somewhere that matches one of the requirejs define forms.

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.