What the agent does
babel-eslint is deprecated on npm with the note that it is now @babel/eslint-parser and will receive no more updates. The rename looks like a one-word edit in the ESLint config, and the agent checks three things first that decide whether it is. In a library like yury-dymov/json-api-normalizer the config is two lines, .eslintrc with "extends": "airbnb" and "parser": "babel-eslint". package.json lists babel-eslint ^10.0.1, eslint ^7.14.0 and @babel/core ^7.1.6, yarn.lock resolves those to ESLint 7.14.0 and Babel 7.12.9, and a .babelrc with @babel/preset-env sits at the root. Lint runs in two places: the lint script, eslint src --ext .js, and webpack.config.js, which adds new ESLintPlugin() so every build lints too.
The first check is the version. The new parser declares peer dependencies on both ESLint and @babel/core, and its latest major asks for much newer releases of each than this project has. Adding the package with no version takes that major: yarn prints two incorrect peer dependency warnings, and eslint then stops before linting a single file with SyntaxError: Cannot use import statement outside a module, because that release is an ES module and ESLint 7 loads parsers with require. So the agent reads the peer ranges from the registry and installs the newest release whose ranges include the locked ESLint and Babel, which here is the 7 line.
The second check is the Babel config. The old parser ignored your Babel configuration and parsed with its own fixed set of syntax plugins. The new one loads the project's real config for every file, and when it finds none it reports Parsing error: No Babel config file detected on line 0 of each file. This repository has a root .babelrc, so nothing more is needed. In a project that keeps Babel options inside a bundler config, the agent sets requireConfigFile: false with explicit babelOptions under parserOptions, and says so. Because the config is now loaded, lint output gains whatever Babel's presets print; here that is Browserslist's notice about outdated caniuse-lite data, which is noise and not a lint result.
The third check is the plugin. Rules from eslint-plugin-babel moved to @babel/eslint-plugin under a new prefix. This project does not use it, and the agent confirms that with a search before skipping the step. It then runs everything that touches the parser, in the order the repository's CI does: install from the lockfile, yarn build, since the tests import ../dist/bundle, then the tests and the lint script. It compares the lint result file by file with the run it saved before the change.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Replace the deprecated babel-eslint parser with @babel/eslint-parser in this repository. First record the baseline: install from the lockfile with the package manager the lockfile belongs to, then run the lint script, the tests and the build exactly as the CI config does, and save the output of each. Use a Node version from the CI matrix; if a command fails on the machine's default Node for a reason unrelated to linting, say so and switch. Find every ESLint config (.eslintrc in any format, eslintConfig in package.json, eslint.config.js, overrides blocks, and any config passed to a bundler plugin or loader) and every place babel-eslint or eslint-plugin-babel is named. Read the resolved versions of eslint and @babel/core from the lockfile. Read the peer dependency ranges of @babel/eslint-parser from the registry for each major and choose the newest release whose ranges include those resolved versions; do not upgrade ESLint or Babel in this change, and if no release fits, stop and report the ranges. Remove babel-eslint, add the chosen version with the same package manager so the lockfile is updated, and change the parser name in each config. Check that Babel can find a config file for the linted files; if the project has none at the root, set parserOptions.requireConfigFile to false with the babelOptions the code needs and explain the choice. If eslint-plugin-babel is used, replace it with @babel/eslint-plugin and rename its rules to the new prefix. Run lint, tests and build again on the same Node version. Compare the lint results with the baseline per file and rule: list any message that appeared or disappeared, and separate real lint messages from notices printed by Babel presets. Do not fix or disable any rule to make the output match. Open a pull request with the peer range table and both sets of output.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request with three changed files: one line in .eslintrc, one line in package.json, and the corresponding entries in yarn.lock. Its description shows the peer range table that led to the version, the baseline and final output of yarn lint, the test summary and the last lines of the webpack build, each with the Node version it ran on.
The reviewer's first question is whether lint reports the same problems as before, and the per-file comparison answers it. A parser change can surface new messages or hide old ones without any rule being edited, because rules see a syntax tree produced by different code. If the comparison lists a difference, the pull request leaves the code and the rules alone and names the file, the rule and both results.
They also read what the agent found on the way. This repository's Travis matrix lists Node 14, 12, 10 and the current release. On a current Node the build fails before and after the change with ERR_OSSL_EVP_UNSUPPORTED, an error that comes from the locked webpack version and has nothing to do with ESLint. The agent runs the proof on Node 14 from the matrix and reports the build failure as a separate, existing problem. eslint-config-airbnb also warns about its own peer range against ESLint 7 during install; that warning is in both logs.
Run it on every repository that still lists babel-eslint
Front-end organisations tend to have this parser in every repository created from the same starter. From a script, find the repositories whose package.json names babel-eslint and send this body to POST /o/{org}/sessions for each, with the repository in resources. The right parser version differs from one repository to the next because it follows that repository's locked ESLint and Babel, which is why each needs its own run and its own table.
Add a request_id that is a UUID v5 of the repository name so a second pass starts nothing new. Calls answer 202 at once; runs past the key's max_concurrent wait as queued. Read each session for its pull request, or have the key's webhook_url receive run.completed.
The use case this job follows, with its automation and trigger: Upgrade dependencies weekly.
Why run it on Rush?
Done by hand, this change is usually tested by running lint once and seeing no red. That misses the case that matters, a parser that silently reports less. The run keeps the complete lint output from before and after and compares them, and both are in the session's transcript beside the commands that produced them. The comparison is a statement the reviewer can check line by line.
It also needs the right runtime. Old toolchains like this one build only on the Node versions their CI names, and a developer's machine rarely has those installed. The sandbox fetches the version from the matrix, runs the baseline and the result on it, and records which version each output came from. When the default Node cannot build the project at all, that is written down as its own finding and not confused with the change under review.
Frequently asked questions
Why do I get "No Babel config file detected" after switching parsers?
@babel/eslint-parser loads your Babel configuration for each file it parses and, by default, refuses to run without one. Add a babel.config.js or .babelrc at the project root, or set requireConfigFile: false under parserOptions and pass the presets it needs in babelOptions. The old parser never read the config, which is why the error is new.
Which version of @babel/eslint-parser should I install?
The newest one whose peer dependency ranges include the ESLint and @babel/core versions in your lockfile. Installing with no version takes the latest major, which may require a newer ESLint, a newer Babel and an ES module loader. The agent prints the ranges for each major and the resolved versions next to them.
Do I still need a Babel parser for ESLint at all?
Only if your code uses syntax ESLint's built-in parser does not understand, such as a proposal enabled through a Babel plugin, or Flow annotations. A project on standard modern JavaScript can often delete the parser line. This run keeps a Babel parser and only replaces the deprecated one. To find out, remove the parser line on a branch and run lint: a parsing error names the syntax that still needs Babel.
Will my lint results change?
They should not, and the run checks. Baseline and final output are compared per file and per rule, and any message that appears or disappears is listed in the pull request. No rule is edited or disabled to force a match.
More jobs like this: Upgrade dependencies weekly
- Migrate a Go Project From Blackfriday to goldmark (Blackfriday)
- Migrate From Bluebird to Native Promises in a Node.js Library (Bluebird)
- Replace body-parser With express.json() in an Express App (body-parser)
- Migrate From the Archived github.com/boltdb/bolt to go.etcd.io/bbolt in a Go Service (BoltDB)
- Migrate From boto to boto3 in a Python Service (boto)
- Convert a CoffeeScript Project to Modern JavaScript With decaffeinate (CoffeeScript)