sindresorhus / callsites

Get callsites from the V8 stack trace API
MIT License
260 stars 22 forks source link

eslint fails on node-chakra #3

Closed alexlamsl closed 8 years ago

alexlamsl commented 8 years ago

This happens when I run eslint sample.js (.eslintrc.js & sample.js both exist)

Cannot read config file: .eslintrc.js
Error: Unable to get property 'getFileName' of undefined or null reference
TypeError: Cannot read config file: .eslintrc.js
Error: Unable to get property 'getFileName' of undefined or null reference
   at module.exports (node_modules\caller-path\index.js:5:2)
   at module.exports (node_modules\require-uncached\index.js:11:2)
   at loadJSConfigFile (node_modules\eslint\lib\config\config-file.js:157:9)
   at loadConfigFile (node_modules\eslint\lib\config\config-file.js:197:13)
   at load (node_modules\eslint\lib\config\config-file.js:437:9)
   at loadConfig (node_modules\eslint\lib\config.js:67:13)
   at getLocalConfig (node_modules\eslint\lib\config.js:129:9)
   at Config.prototype.getConfig (node_modules\eslint\lib\config.js:223:9)
   at processText (node_modules\eslint\lib\cli-engine.js:155:5)
   at processFile (node_modules\eslint\lib\cli-engine.js:227:9)

Reading the source code, Error.prepareStackTrace may be a V8-specific trick that won't work on ChakraCore.

alexlamsl commented 8 years ago

A tested (on node-chakracore) workaround which addresses this issue:

'use strict';
module.exports = function () {
    return new Error().stack.split(/\n/).slice(1).map(function(line) {
        var filename = line.match(/\((.*?)\:[0-9]+\:[0-9]+\)/)[1];
        return {
            getFileName: function() {
                return filename;
            }
        };
    });
};
sindresorhus commented 8 years ago

Please don't open issues about node-chakra on people's projects. node-chakra should be V8 compatible. If it's not, it's up to the Chakra team to fix their compatibility layer.