I get a bunch of errors regarding linting. I have ...
# help
p
I get a bunch of errors regarding linting. I have tried to add a
.eslintignore
file with just a single
*
in, but lines like these spam my screen on `sst start`:
Copy code
/Users/pal/dev/peasy/node_modules/@aws-cdk/cx-api/lib/cloud-assembly.js
 0:0 warning File ignored by default. Use "--ignore-pattern '!node_modules/*'" to override
That a file is (correctly) ignored seems like TMI. Any ideas on how to supress this?
j
Can you give me a quick sense of your dir structure? Also, do you get these errors when you run
sst build
? or is it just for
sst start
?
p
Both
start
&
build
Copy code
lib/
   index.js
   logger.js
   db-util.js
   etc.js
sst/
   stack-a-definition.js
   stack-b-definition.js
   common.js
services/
   service-a/
      serverless.yml
      service-a-handler.js
      service-a-handler.test.js
   service-b/
      ...
   service-z/
      ...
package.json
sst.json
.eslintignore
yarn.lock
...
I normally use standard JS for my stuff, and adding this
.eslintignore
file disrupts those settings, but I have removed standard for now
Also, if I don't add * to `.eslintignore`I'm unable to deploy due to various errors such as:
Copy code
/Users/pal/dev/peasy/services/analysis/profiler.js
 46:24 error 'process' is not defined no-undef
 58:21 error 'console' is not defined no-undef

/Users/pal/dev/peasy/lib/db.js
  11:23 error 'process' is not defined no-undef
 370:12 error 'Promise' is not defined no-undef
 425:12 error 'Promise' is not defined no-undef
 502:51 error 'Set' is not defined   no-undef
j
We have a fix for the
process
and
console
not being defaulted on the way. But let me look at the other errors you are getting today.
Can I try it in the sample repo you shared yesterday?
p
Let me check if it turns up there or only in my 'big' repo
If you clone that repo and run
yarn add standard
I think you might see some error, checking more now
If I do that I get another error:
Copy code
yarn sst build                                                             17:30:57
yarn run v1.22.10
$ /Users/pal/temp/sst-eu-example/node_modules/.bin/sst build
Preparing your SST app
Transpiling source
Linting source
Error: Failed to load plugin '@typescript-eslint' declared in 'BaseConfig#overrides[0]': Cannot find module '@typescript-eslint/eslint-plugin'
Require stack:
- /Users/pal/temp/sst-eu-example/__placeholder__.js
Referenced from: BaseConfig#overrides[0]
  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
  at Function.resolve (internal/modules/cjs/helpers.js:94:19)
  at Object.resolve (/Users/pal/temp/sst-eu-example/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js:28:50)
  at ConfigArrayFactory._loadPlugin (/Users/pal/temp/sst-eu-example/node_modules/@eslint/eslintrc/lib/config-array-factory.js:1011:39)
  at ConfigArrayFactory._loadExtendedPluginConfig (/Users/pal/temp/sst-eu-example/node_modules/@eslint/eslintrc/lib/config-array-factory.js:831:29)
  at ConfigArrayFactory._loadExtends (/Users/pal/temp/sst-eu-example/node_modules/@eslint/eslintrc/lib/config-array-factory.js:778:29)
  at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/pal/temp/sst-eu-example/node_modules/@eslint/eslintrc/lib/config-array-factory.js:719:25)
  at _normalizeObjectConfigDataBody.next (<anonymous>)
  at ConfigArrayFactory._normalizeObjectConfigData (/Users/pal/temp/sst-eu-example/node_modules/@eslint/eslintrc/lib/config-array-factory.js:664:20)
  at _normalizeObjectConfigData.next (<anonymous>) {
 code: 'MODULE_NOT_FOUND',
 requireStack: [ '/Users/pal/temp/sst-eu-example/__placeholder__.js' ],
 messageTemplate: 'plugin-missing',
 messageData: {
  pluginName: '@typescript-eslint/eslint-plugin',
  resolvePluginsRelativeTo: '/Users/pal/temp/sst-eu-example',
  importerName: 'BaseConfig#overrides[0]'
 }
}
There was a problem linting the source.
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
sorry,
yarn add standard -D
is more correct, but either will lead to the error shown AFAIK
And this is not the original error, but rather a new that also seems to depend on linting
j
I see. Got it. Let me take a look at it today.
The issue is with peerDependencies for the ESLint setup we are using. We'l push a fix for it today.
p
ah, nice to hear! Thanks for that!
j
Just an update, the new release fixes one of the issues you were having (lint plugins not found for the cdk code) but I need to do the same for the Lambdas as well.
I pushed out a patch and tested it with your repo and that seems fine — https://github.com/serverless-stack/serverless-stack/releases/tag/v0.7.1
But I suspect, if you are using standard, we'll need an option to turn off linting in SST.
p
Awesome!