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

Linting fails due to upstream configuration difference #11

Closed
lookitsatravis opened this issue Oct 22, 2020 · 3 comments
Closed

Linting fails due to upstream configuration difference #11

lookitsatravis opened this issue Oct 22, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@lookitsatravis
Copy link

lookitsatravis commented Oct 22, 2020

Hello! I'm getting the following error after a basic yarn create serverless-stack resources. I installed the stack into a subdirectory of a project which has it's own ESLint configuration. I get the following error during yarn build:

❯ yarn build                                                                                                                                               took   4s   12.18.3   2.4.0
yarn run v1.22.10
$ sst build
Preparing @serverless-stack/resources
Linting source

Oops! Something went wrong! :(

ESLint: 7.11.0

ESLint couldn't determine the plugin "@typescript-eslint" uniquely.

- /Users/me/some-app/infrastructure/node_modules/@serverless-stack/cli/node_modules/@typescript-eslint/eslint-plugin/dist/index.js (loaded in "--config")
- /Users/me/some-app/node_modules/@typescript-eslint/eslint-plugin/dist/index.js (loaded in "../.eslintrc.js » plugin:@typescript-eslint/recommended » ./configs/base")

Please remove the "plugins" setting from either config or remove either plugin installation.

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Seems this can be resolved by making sure the CLI's ESLint process treats itself as the root via --resolve-plugins-relative-to . This could also be solved by allowing me to specify my own ESLint config to sst, or by letting end users skip linting altogether.

@jayair
Copy link
Contributor

jayair commented Oct 24, 2020

Ah let me have a look at this. Is your SST app installed one directory inside your project root?

@jayair jayair added the bug Something isn't working label Oct 24, 2020
@lookitsatravis
Copy link
Author

Yes, so my project looks a bit like this:

my-app/
├─ infrastructure/
│  ├─ sst.json
│  ├─ package.json
├─ .eslintrc.js
├─ node_modules/
├─ package.json

I'm using that ESLint config for other files in the same repo. I suppose it's worth it to mention that I'm using Yarn workspaces and the infrastructure directory is included in that configuration. I patched it locally via patch-package with the following patch:

# patch file named @serverless-stack+cli+0.4.2.patch

diff --git a/node_modules/@serverless-stack/cli/scripts/config/cdkHelpers.js b/node_modules/@serverless-stack/cli/scripts/config/cdkHelpers.js
index f473dba..ddc8b4a 100644
--- a/node_modules/@serverless-stack/cli/scripts/config/cdkHelpers.js
+++ b/node_modules/@serverless-stack/cli/scripts/config/cdkHelpers.js
@@ -128,6 +128,8 @@ function lint() {
       ".js,.ts",
       "--fix",
       "lib/**",
+      "--resolve-plugins-relative-to",
+      ".",
     ],
     { stdio: "inherit", cwd: paths.appPath }
   );

@jayair jayair closed this as completed in 61a4562 Oct 27, 2020
@jayair
Copy link
Contributor

jayair commented Oct 27, 2020

Yup makes sense. Thanks for sharing the patch.

Just pushed out a new release with it:

https://github.com/serverless-stack/serverless-stack/releases/tag/v0.4.3

SolP-Aleios pushed a commit to SolP-Aleios/sst that referenced this issue Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants