SAP / jenkins-library

Jenkins shared library for Continuous Delivery pipelines.
https://www.project-piper.io
Apache License 2.0
779 stars 590 forks source link

npmExecuteLint fails with custom config #4086

Closed uxkjaer closed 1 year ago

uxkjaer commented 1 year ago

I'm doing a POC for a customer to showcase the CI/CD service in BTP.

I want the linting to run using the NPM package eslint-plugin-fiori-custom.

Below is my eslint config

.eslintrc

{
  "plugins": ["eslint-plugin-fiori-custom"],
  "extends": [ "eslint:recommended","./node_modules/eslint-plugin-fiori-custom/configure.eslintrc"],
  "ignorePatterns": ["webapp/localservice/**", "webapp/test/**","test/**","wdio.conf.js", "dist/**"]
}

when running the ci-lint script I have to run the eslint command via npx eslint and also npm install beforehand otherwise there is no node_modules folder.

Working script

   "ci-lint": "npm install &&  npm run lint",
    "lint": "npx eslint ./ --fix --rulesdir ./node_modules/eslint-plugin-fiori-custom/lib/rules/",

Actual output

without the npm install it fails.

Example running command ls ./node_modules

[2022-10-26T01:34:30.706Z] info  npmExecuteLint - running command: npm run ci-lint --silent
[2022-10-26T01:34:30.747Z] info  npmExecuteLint - ls: ./node_modules/: No such file or directory

Example runnnig npx eslint with rulesdir

[2022-10-26T01:23:49.248Z] info  npmExecuteLint - run-script ci-lint
[2022-10-26T01:23:49.311Z] info  npmExecuteLint - running command: npm run ci-lint --silent
[2022-10-26T01:23:53.518Z] info  npmExecuteLint - 
[2022-10-26T01:23:53.557Z] info  npmExecuteLint - Oops! Something went wrong! :(
[2022-10-26T01:23:53.591Z] info  npmExecuteLint - 
[2022-10-26T01:23:53.629Z] info  npmExecuteLint - ESLint: 8.26.0
[2022-10-26T01:23:53.668Z] info  npmExecuteLint - 
[2022-10-26T01:23:53.704Z] info  npmExecuteLint - Error: ENOENT: no such file or directory, scandir '/home/jenkins/agent/workspace/Push/node_modules/eslint-plugin-fiori-custom/lib/rules'

Example running eslint without npx

2022-10-25T12:50:10.399Z] info  npmExecuteLint - run-script ci-lint
[2022-10-25T12:50:10.459Z] info  npmExecuteLint - running command: npm run ci-lint --silent
[2022-10-25T12:50:11.098Z] info  npmExecuteLint - sh: eslint: not found

Expected output:

The documentation should reflect the need to have a ci-lint script as most projects have a lint script instead. There shouldn't be a need to run npm install before executing the linting.

github-actions[bot] commented 1 year ago

Thank you for your contribution! This issue is stale because it has been open 60 days with no activity. In order to keep it open, please remove stale label or add a comment within the next 10 days. If you need a Piper team member to remove the stale label make sure to add @SAP/jenkins-library-team to your comment.

github-actions[bot] commented 1 year ago

Issue got stale and no further activity happened. It has automatically been closed. Please re-open in case you still consider it relevant.