Skip to content

Lint script fails due to parsing errors #532

@mike-phillips

Description

@mike-phillips

Issue Summary

yarn run lint fails for a brand new project created with gatsby-starter-ghost

➜  gatsby-starter-ghost git:(main) yarn run lint
yarn run v1.22.19
$ eslint . --ext .js --cache

/Users/mike/src/gatsby-starter-ghost/.eslintrc.js
  0:0  error  Parsing error: require() of ES Module /Users/mike/src/gatsby-starter-ghost/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/mike/src/gatsby-starter-ghost/node_modules/babel-eslint/lib/require-from-eslint.js not supported.
Instead change the require of definition.js in /Users/mike/src/gatsby-starter-ghost/node_modules/babel-eslint/lib/require-from-eslint.js to a dynamic import() which is available in all CommonJS modules
...

To Reproduce

  1. gatsby new example-project https://github.com/TryGhost/gatsby-starter-ghost.git
  2. cd example-project
  3. yarn install
  4. yarn run lint

I think this is a bug because it adds work to getting basic CI/CD up-and-running for every new project created with this tool.

The impact may be minor if the user is capable of debugging and resolving the issues. Probably depends on the experience of the developer and how much they care about having these commands working.

Technical details:

  • Ghost Version: N/A as far as I'm aware
  • Gatsby CLI version: 4.20.0
  • Gatsby version: 4.15.2
  • gatsby-starter-ghost Version: 2.0.0
  • Node Version: 16.16.0
  • OS: Mac

Resolution Notes

Others encountering this issue have resolved the problem by migrating from babel-eslint (deprecated as of March 2020) to @babel/eslint-parser.

I plan to put up a pull request that:

  1. does the migration from babel-eslint to @babel/eslint-parser
  2. adds a lint-fix script
  3. applies automated fixes to any existing eslint issues
  4. applies inline ignores to any remaining eslint issues (unless the fixes are obvious)

It'd be great to add a github action that ensures the linting is passing for any pull requests to the main branch but that seems out of scope for the initial fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions