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

JS-192 Build working esling-plugin-sonarjs package #4750

Open
wants to merge 72 commits into
base: master
Choose a base branch
from

Conversation

ilia-kebets-sonarsource
Copy link
Contributor

Fixes #

@ilia-kebets-sonarsource ilia-kebets-sonarsource changed the title JS-192 Release esling-plugin-sonarjs JS-192 Build working esling-plugin-sonarjs package Jul 8, 2024
@ilia-kebets-sonarsource ilia-kebets-sonarsource marked this pull request as ready for review July 8, 2024 07:06
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't manage to run it programmatically without using the linter API, but I believe that what we want to test is CLI usage.

package.json Outdated
@@ -29,7 +32,8 @@
"_:plugin:prepare-bridge": "npm pack && node tools/check-distribution-filepath-length.js && npm run _:plugin:copy-bridge",
"_:plugin-fetch-node": "node tools/fetch-node/scripts/wrapper.mjs",
"_:plugin:pre-build": "npm run bridge:build && npm run _:plugin:prepare-bridge && npm run _:plugin-fetch-node",
"_:plugin:copy-bridge": "cpy sonarjs-1.0.0.tgz sonar-plugin/sonar-javascript-plugin/target/classes && cpy sonarjs-1.0.0.tgz sonar-plugin/standalone/target/classes"
"_:plugin:copy-bridge": "cpy sonarjs-1.0.0.tgz sonar-plugin/sonar-javascript-plugin/target/classes && cpy sonarjs-1.0.0.tgz sonar-plugin/standalone/target/classes",
"eslint-plugin:pack": "cpy lib packages/eslint-plugin-sonarjs && npm pack --workspaces && rm -rf packages/eslint-plugin-sonarjs/lib"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I could move this to packages/eslint-plugin-sonarjs/package.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot load all of linter because of:

    Cannot find module '@sonar/shared' from 'node_modules/eslint-plugin-sonarjs/lib/jsts/src/linter/config/linter-config.js'

    Require stack:
      node_modules/eslint-plugin-sonarjs/lib/jsts/src/linter/config/linter-config.js
      node_modules/eslint-plugin-sonarjs/lib/jsts/src/linter/config/index.js
      node_modules/eslint-plugin-sonarjs/lib/jsts/src/linter/index.js
      node_modules/eslint-plugin-sonarjs/lib/jsts/src/rules/S2699/rule.js
      node_modules/eslint-plugin-sonarjs/lib/jsts/src/rules/S2699/index.js
      node_modules/eslint-plugin-sonarjs/lib/eslint-plugin-sonarjs/src/index.js
      test/unit/index.test.ts

rules['xml-parser-xxe'] = S2755;
rules['xpath'] = S4817;

//import { name, version } from '../package.json';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find some solution for this: the path is different in the transpiled code, so it fails when running the generated package.


cd its/eslint-plugin-sonarjs

rm -rf node_modules/eslint-plugin-sonarjs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this is not necessary anymore

Base automatically changed from merge-eslint-plugin to master July 8, 2024 14:35
Copy link

sonarqube-next bot commented Jul 8, 2024

Quality Gate failed Quality Gate failed

Failed conditions
84 New issues
82.1% Coverage on New Code (required ≥ 90%)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

@ilia-kebets-sonarsource
Copy link
Contributor Author

here were the issues I ran into for a few rules that I had decided to omit from the package:

TypeError: context.getFirstTokens is not a function
Occurred while linting /private/tmp/test-plugin/file.js:1
Rule: "sonarjs/jsx-no-constructed-context-values"
    at Object.isAnnotatedFunctionPropsDeclaration (/private/tmp/test-plugin/node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react/lib/util/annotations.js:22:26)
    at markAnnotatedFunctionArgumentsAsDeclared (/private/tmp/test-plugin/node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react/lib/util/propTypes.js:1030:41)
    at /private/tmp/test-plugin/node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react/lib/util/Components.js:277:9
    at Array.forEach (<anonymous>)
    at mergedHandler (/private/tmp/test-plugin/node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react/lib/util/Components.js:276:16)
    at ruleErrorHandler (/private/tmp/test-plugin/node_modules/eslint/lib/linter/linter.js:1113:48)
    at /private/tmp/test-plugin/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/private/tmp/test-plugin/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/private/tmp/test-plugin/node_modules/eslint/lib/linter/node-event-generator.js:297:26)



TypeError: Cannot read properties of undefined (reading 'some')
Occurred while linting /private/tmp/test-plugin/file.js:1
Rule: "sonarjs/no-inconsistent-returns"
    at checkFunctionForImplicitReturn (/private/tmp/test-plugin/node_modules/eslint-plugin-sonarjs/lib/jsts/src/rules/S3801/rule.js:64:95)
    at checkFunctionLikeDeclaration (/private/tmp/test-plugin/node_modules/eslint-plugin-sonarjs/lib/jsts/src/rules/S3801/rule.js:50:13)
    at checkOnFunctionExit (/private/tmp/test-plugin/node_modules/eslint-plugin-sonarjs/lib/jsts/src/rules/S3801/rule.js:43:47)
    at ruleErrorHandler (/private/tmp/test-plugin/node_modules/eslint/lib/linter/linter.js:1113:48)
    at /private/tmp/test-plugin/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/private/tmp/test-plugin/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/private/tmp/test-plugin/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/private/tmp/test-plugin/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.leaveNode (/private/tmp/test-plugin/node_modules/eslint/lib/linter/node-event-generator.js:349:14)
    $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants