Eslint-plugin-react: `console.log` causes a "EPERM: operation not permitted, write" in Atom editor

Created on 23 Aug 2016  路  3Comments  路  Source: yannickcr/eslint-plugin-react

The bug has since been reported in several places but the cause is using console.log unsafely in the eslint-plugin-react.

Here's the exception that pops up in Atom:

Error: EPERM: operation not permitted, write
    at Error (native)
    at Object.fs.writeSync (fs.js:706:20)
    at SyncWriteStream.write (fs.js:2064:6)
    at Console.log (console.js:39:16)
    at EventEmitter.Program (__CENSORED__\node_modules\eslint-plugin-react\lib\rules\require-extension.js:103:17)
    at emitOne (events.js:95:20)
    at EventEmitter.emit (events.js:182:7)
    at NodeEventGenerator.enterNode (__CENSORED__\node_modules\eslint\lib\util\node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (__CENSORED__\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (__CENSORED__\node_modules\eslint\lib\util\comment-event-generator.js:97:23)

Here's one of the faulty lines:
https://github.com/yannickcr/eslint-plugin-react/blob/v3.16.1/lib/rules/jsx-quotes.js#L52

      /* eslint-disable no-console */
      console.log('The react/jsx-quotes rule is deprecated. Please use the jsx-quotes rule instead.');
      /* eslint-enable no-console */
      isWarnedForDeprecation = true;

There are more occurences of this pattern:
https://github.com/yannickcr/eslint-plugin-react/blob/e84af68a3bf48c9a34f14e73a8b4dc1ed7488bab/lib/rules/require-extension.js#L103

        /* eslint-disable no-console */
        console.log('The react/require-extension rule is deprecated. Please ' +
                    'use the import/extensions rule from eslint-plugin-import instead.');
        /* eslint-enable no-console */
        isWarnedForDeprecation = true;

https://github.com/yannickcr/eslint-plugin-react/search?utf8=%E2%9C%93&q=console.log&type=Code

Please consider wrapping console.log in a try..catch or removing it entirely, because the eslint plugin is supposed to run in a multitude of environments without errors, but implying a valid console is an unreasonably strict requirement.

wontfix

Most helpful comment

All 3 comments

This is a node module. It is meant to run in node, which has console. It is a perfectly valid requirement. There is no unsafe way to use console methods in a node module.

Thanks, that's the right place to fix it :-)

Was this page helpful?
0 / 5 - 0 ratings