asyncapi / spec-json-schemas

AsyncAPI schema versions
Apache License 2.0
56 stars 54 forks source link

ci: added code linting #473

Closed Gmin2 closed 10 months ago

Gmin2 commented 11 months ago

Description this pr introduces linting in the repo Related issue(s) fix #467

smoya commented 11 months ago

@Min2who please update the title of the PR according to the semantic-release prefixes (as shown in the checks). In this case, the prefix is ci.

AnimeshKumar923 commented 11 months ago

@smoya sorry to bother but the workflow requires your approval

smoya commented 11 months ago

@Min2who Can this be turned in to a final PR? Looks ok to me.

Gmin2 commented 11 months ago

@Min2who Can this be turned in to a final PR? Looks ok to me.

@smoya done

smoya commented 11 months ago

@Min2who PR Testing workflow is failing https://github.com/asyncapi/spec-json-schemas/actions/runs/7250263375/job/19767638609?pr=473#step:11:31

smoya commented 11 months ago

The tests are now failing because of linting issues 👍 Perhaps it makes sense to run a npm run lint:fix and commit the result here.

Gmin2 commented 11 months ago

@smoya if i dont add comment disabling the eslint error it fails npm run lint and if i do as in this case it is failing sonarcloud code analysis what should i do

AnimeshKumar923 commented 11 months ago

Hey @smoya @Min2who :wave: I tried doing the steps you provided in the issue and I'm also getting the same issue as the one which SonarCloud is giving.

After running npm run lint, the following output is being given :point_down:

> @asyncapi/specs@6.2.0 lint
> eslint --max-warnings 0 --config .eslintrc.yml .

Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'security' -> object with constructor 'Object'
    |     property 'configs' -> object with constructor 'Object'
    |     property 'recommended' -> object with constructor 'Object'
    --- property 'plugins' closes the circle
Referenced from: /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/.eslintrc.yml
    at JSON.stringify (<anonymous>)
    at /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:45
    at Array.map (<anonymous>)
    at ConfigValidator.formatErrors (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2147:23)
    at ConfigValidator.validateConfigSchema (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:84)
    at ConfigArrayFactory._normalizeConfigData (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
    at ConfigArrayFactory._loadExtendedPluginConfig (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3239:25)
    at ConfigArrayFactory._loadExtends (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3154:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3095:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)

@smoya currently I'm not having that much knowledge to debug this :sweat_smile: . You'd know better as you've knowledge of the codebase and how things are working internally, so would require you help here...

smoya commented 10 months ago

Hey @smoya @Min2who 👋 I tried doing the steps you provided in the issue and I'm also getting the same issue as the one which SonarCloud is giving.

After running npm run lint, the following output is being given 👇

> @asyncapi/specs@6.2.0 lint
> eslint --max-warnings 0 --config .eslintrc.yml .

Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'security' -> object with constructor 'Object'
    |     property 'configs' -> object with constructor 'Object'
    |     property 'recommended' -> object with constructor 'Object'
    --- property 'plugins' closes the circle
Referenced from: /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/.eslintrc.yml
    at JSON.stringify (<anonymous>)
    at /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:45
    at Array.map (<anonymous>)
    at ConfigValidator.formatErrors (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2147:23)
    at ConfigValidator.validateConfigSchema (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:84)
    at ConfigArrayFactory._normalizeConfigData (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
    at ConfigArrayFactory._loadExtendedPluginConfig (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3239:25)
    at ConfigArrayFactory._loadExtends (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3154:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3095:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)

@smoya currently I'm not having that much knowledge to debug this 😅 . You'd know better as you've knowledge of the codebase and how things are working internally, so would require you help here...

I can't reproduce this error. Ran this locally and worked fine.

Gmin2 commented 10 months ago

@smoya if i dont add comment disabling the eslint error it fails npm run lint and if i do as in this case it is failing sonarcloud code analysis what should i do

@smoya what can i do about this

smoya commented 10 months ago

@smoya if i dont add comment disabling the eslint error it fails npm run lint and if i do as in this case it is failing sonarcloud code analysis what should i do

@smoya what can i do about this

npm lint is missing the same lint errors you see in Sonarcloud because of https://github.com/asyncapi/spec-json-schemas/pull/473#discussion_r1445224491

First remove that line, then fix the issues the linter complains about.

Gmin2 commented 10 months ago

@smoya it is ready for review

AnimeshKumar923 commented 10 months ago

Hey @smoya @Min2who 👋 I tried doing the steps you provided in the issue and I'm also getting the same issue as the one which SonarCloud is giving. After running npm run lint, the following output is being given 👇

> @asyncapi/specs@6.2.0 lint
> eslint --max-warnings 0 --config .eslintrc.yml .

Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'security' -> object with constructor 'Object'
    |     property 'configs' -> object with constructor 'Object'
    |     property 'recommended' -> object with constructor 'Object'
    --- property 'plugins' closes the circle
Referenced from: /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/.eslintrc.yml
    at JSON.stringify (<anonymous>)
    at /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:45
    at Array.map (<anonymous>)
    at ConfigValidator.formatErrors (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2147:23)
    at ConfigValidator.validateConfigSchema (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:84)
    at ConfigArrayFactory._normalizeConfigData (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
    at ConfigArrayFactory._loadExtendedPluginConfig (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3239:25)
    at ConfigArrayFactory._loadExtends (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3154:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3095:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)

@smoya currently I'm not having that much knowledge to debug this 😅 . You'd know better as you've knowledge of the codebase and how things are working internally, so would require you help here...

I can't reproduce this error. Ran this locally and worked fine.

It seems it's no longer giving the error. But a different error this time which is mentioned here in the 2nd screenshot: https://github.com/asyncapi/spec-json-schemas/pull/473#discussion_r1446224583

Gmin2 commented 10 months ago

Hey @smoya @Min2who 👋 I tried doing the steps you provided in the issue and I'm also getting the same issue as the one which SonarCloud is giving. After running npm run lint, the following output is being given 👇

> @asyncapi/specs@6.2.0 lint
> eslint --max-warnings 0 --config .eslintrc.yml .

Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'security' -> object with constructor 'Object'
    |     property 'configs' -> object with constructor 'Object'
    |     property 'recommended' -> object with constructor 'Object'
    --- property 'plugins' closes the circle
Referenced from: /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/.eslintrc.yml
    at JSON.stringify (<anonymous>)
    at /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:45
    at Array.map (<anonymous>)
    at ConfigValidator.formatErrors (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2147:23)
    at ConfigValidator.validateConfigSchema (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:84)
    at ConfigArrayFactory._normalizeConfigData (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
    at ConfigArrayFactory._loadExtendedPluginConfig (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3239:25)
    at ConfigArrayFactory._loadExtends (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3154:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3095:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)

@smoya currently I'm not having that much knowledge to debug this 😅 . You'd know better as you've knowledge of the codebase and how things are working internally, so would require you help here...

I can't reproduce this error. Ran this locally and worked fine.

It seems it's no longer giving the error. But a different error this time which is mentioned here in the 2nd screenshot: #473 (comment)

If we use espree parser (the default eslint parser) then this error occur.But if we use babel-eslint parser this error does not occur

smoya commented 10 months ago

Hey @smoya @Min2who 👋 I tried doing the steps you provided in the issue and I'm also getting the same issue as the one which SonarCloud is giving. After running npm run lint, the following output is being given 👇

> @asyncapi/specs@6.2.0 lint
> eslint --max-warnings 0 --config .eslintrc.yml .

Oops! Something went wrong! :(

ESLint: 8.56.0

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'security' -> object with constructor 'Object'
    |     property 'configs' -> object with constructor 'Object'
    |     property 'recommended' -> object with constructor 'Object'
    --- property 'plugins' closes the circle
Referenced from: /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/.eslintrc.yml
    at JSON.stringify (<anonymous>)
    at /home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2156:45
    at Array.map (<anonymous>)
    at ConfigValidator.formatErrors (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2147:23)
    at ConfigValidator.validateConfigSchema (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2177:84)
    at ConfigArrayFactory._normalizeConfigData (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3019:19)
    at ConfigArrayFactory._loadExtendedPluginConfig (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3239:25)
    at ConfigArrayFactory._loadExtends (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3154:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/home/animeshkumar923/Desktop/open-source/asyncapi-spec-json-schemas/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3095:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)

@smoya currently I'm not having that much knowledge to debug this 😅 . You'd know better as you've knowledge of the codebase and how things are working internally, so would require you help here...

I can't reproduce this error. Ran this locally and worked fine.

It seems it's no longer giving the error. But a different error this time which is mentioned here in the 2nd screenshot: #473 (comment)

If we use espree parser (the default eslint parser) then this error occur.But if we use babel-eslint parser this error does not occur

But that error is expected. We should fix the code and not hiding it by using another eslint parser.

AnimeshKumar923 commented 10 months ago

But that error is expected. We should fix the code and not hiding it by using another eslint parser.

I think we should create a new issue and proceed to resolve it and then after resolution the linting would pass.

Thoughts?

smoya commented 10 months ago

But that error is expected. We should fix the code and not hiding it by using another eslint parser.

I think we should create a new issue and proceed to resolve it and then after resolution the linting would pass.

Thoughts?

I don't mind if done here or outside.

I dropped a suggestion on how to fix it (ugly but 🤷 ) https://github.com/asyncapi/spec-json-schemas/pull/473/files#r1449018980

AnimeshKumar923 commented 10 months ago

But that error is expected. We should fix the code and not hiding it by using another eslint parser.

I think we should create a new issue and proceed to resolve it and then after resolution the linting would pass. Thoughts?

I don't mind if done here or outside.

I dropped a suggestion on how to fix it (ugly but 🤷 ) https://github.com/asyncapi/spec-json-schemas/pull/473/files#r1449018980

If it's not that significant of a change (assuming it won't stretch out too far if we implement it), I think it would be okay do it in this PR itself. :+1:

Gmin2 commented 10 months ago

But that error is expected. We should fix the code and not hiding it by using another eslint parser.

I think we should create a new issue and proceed to resolve it and then after resolution the linting would pass. Thoughts?

I don't mind if done here or outside. I dropped a suggestion on how to fix it (ugly but 🤷 ) https://github.com/asyncapi/spec-json-schemas/pull/473/files#r1449018980

If it's not that significant of a change (assuming it won't stretch out too far if we implement it), I think it would be okay do it in this PR itself. 👍

@AnimeshKumar923 doing this change in this pr only after completing #482

AnimeshKumar923 commented 10 months ago

@Min2who I think you can start working on this one now as #482 got resolved.

Gmin2 commented 10 months ago

@Min2who I think you can start working on this one now as #482 got resolved.

done @AnimeshKumar923 👍

sonarcloud[bot] commented 10 months ago

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

smoya commented 10 months ago

pinging random mantainers to review besides me @dalelane @char0n

smoya commented 10 months ago

/rtm

asyncapi-bot commented 10 months ago

:tada: This PR is included in version 6.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: