ESLint throws strange error on new builds and old passing builds

Hi everyone,

We’ve been using CircleCI for months with minimal issues, but this one is particularly concerning:

Our builds run ESLint and we had some branches fail two days ago. We decided to address those problems today and found that the failure/error message was this:

sourceCode.getCommentsBefore is not a function
TypeError: sourceCode.getCommentsBefore is not a function
    at Object.fix (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint-plugin-react/lib/rules/jsx-curly-spacing.js:256:46)
    at RuleContext.report (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint/lib/rule-context.js:127:34)
    at reportNoEndingSpace (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint-plugin-react/lib/rules/jsx-curly-spacing.js:250:15)
    at EventEmitter.validateBraceSpacing (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint-plugin-react/lib/rules/jsx-curly-spacing.js:368:11)
    at EventEmitter.emit (events.js:165:20)
    at NodeEventGenerator.applySelector (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint/lib/util/node-event-generator.js:294:22)
    at NodeEventGenerator.enterNode (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint/lib/util/node-event-generator.js:308:14)
    at CodePathAnalyzer.enterNode (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:602:23)
    at CommentEventGenerator.enterNode (/home/circleci/epigrammar/priv/epigrammar/node_modules/eslint/lib/util/comment-event-generator.js:98:23)

Running ESLint on those branches locally went smoothly. No errors. Rebuilding on CircleCI led to failure at the same spot. Then we decided to rebuild previous commits to that branch that had passed. We started getting failures. Now we were very concerned. We tried rebuilding our master branch, which should ALWAYS pass on CircleCI (as no branch that fails on CircleCI is allowed to be merged into master). Master failed too!

We thought maybe ESLint got upgraded while we weren’t looking, and sure enough it had. But our package.json was such that the update was outside the version range we set for ESLint. Inspecting the container also confirmed that the version running on Circle was the same as the one we have locally.

After talking to some of the folks at the eslint Gitter chat, I’ve decided that I should come here in case this is a Circle problem. Has anyone ever experienced an issue like this before?

What base image are you using? Are you using Circle 2.0? May we see your config YAML file? I wonder if it is possible to hardwire to a specific version of things you need (ESLint) to avoid this issue.

One approach is to take a clean base image and manually install things you need, either in your build process, or in a custom Docker image that is used as your Circle base.