Home > Software engineering >  eslint warning is failing the gitlab CI
eslint warning is failing the gitlab CI

Time:11-18

I'm using React with Typescript. Locally i configured eslint to treat unused variable as warning.

When i run npm run build locally it work, but in gitlab ci i'm getting this error :

 npm run build
> [email protected] build
> react-scripts build
Creating an optimized production build...
Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.
Failed to compile.
[eslint] 
src/common/components/MAppBar/MAppBar.tsx
  Line 4:8:   'Divider' is defined but never used         no-unused-vars
  Line 4:8:   'Divider' is defined but never used         @typescript-eslint/no-unused-vars

You can see the gitlab repo in question here. Where .eslintrc.js and .gitlab-ci.yml are well configured to me.

How to tell Gitlab CI to ignore warning ??

ps: i want to build in order to serve the app in gitlab pages

CodePudding user response:

You need to set your CI environment variable to false. See this line in the log you posted:

Treating warnings as errors because process.env.CI = true.

To get GitLab CI to ignore this, you should set CI = "false" in the variables section of your '.gitlab-ci.yml' (https://gitlab.com/anesboz/optimal-move/-/blob/feature/ci-cd/.gitlab-ci.yml#L7)

  • Related