Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPE-4417] SDK in project using new ESLint flat config file causes linting errors #1057

Open
MattDClarke opened this issue Nov 4, 2024 · 1 comment
Labels

Comments

@MattDClarke
Copy link

MattDClarke commented Nov 4, 2024

When generating an SDK using the speakeasy quickstart command in a directory that uses the new ESLint flat config file, eslintrc.js, the SDK folder is created but I get linting errors in the terminal:


...
86:66  error  Strings must use singlequote                                                               style/quotes
87:5   error  Closing curly brace appears on the same line as the subsequent block                       style/brace-
...

I don't get the error if I run the speakeasy quickstart command from outside the project or in a project that uses the old ESLint config file format, eslintrc.js.

I guess the error occurs because of the configuration file resolution. When ESLint is run on the command line, it first checks the current working directory for an eslint.config.js, eslint.config.mjs, or eslint.config.cjs file. If none of the files are found, it checks the parent directory for each file - the project's eslintrc.js file, which finds linting errors in the SDK folder.

Speakeasy targets customers who want to publish SDKs as standalone npm packages, where this issue won't occur.
However, this issue may occur for users who are testing out Speakeasy.


Steps

  1. Clone the repository:
git clone https://github.com/speakeasy-api/speakeasy-hono-example.git
  1. Navigate into the project directory:
cd speakeasy-hono-openapi-sdk-starter
  1. Install all dependencies for the application using NPM:
npm install
  1.  Create a Speakeasy SDK:
speakeasy quickstart

Expected result

No ESLint errors


Actual result

Linting errors caused by the project's eslint.config.mjs file:

...
86:66  error  Strings must use singlequote                                                               style/quotes
87:5   error  Closing curly brace appears on the same line as the subsequent block                       style/brace-
...

Workaround

Run the speakeasy quickstart command from outside the project.


Potential solution

Eslint recommends migrating to the new flat config system. If that's not an option you can keep using .eslintrc.cjs,by preventing the search for eslint.config.js using the -c or --config option on the command line to specify an alternate configuration file. In the SDK package.json file, adding --config .eslintrc.cjs to the lint script might prevent the error.

SPE-4417

@simplesagar
Copy link
Member

Hi @MattDClarke Thanks for the report ! We'll take a look

@simplesagar simplesagar changed the title SDK in project using new ESLint flat config file causes linting errors [SPE-4417] SDK in project using new ESLint flat config file causes linting errors Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants