我正在尝试使用 Linux 运行程序设置 gitlab CI/CD。我遇到了一些问题,首先它找不到 eslint 作为命令,在全局安装它之后,由于某种原因它可以工作,但现在我遇到了找不到全局变量的问题。谁能帮我解决这个问题吗?这是我的
eslint.config.mjs
:
import globals from "globals";
import pluginJs from "@eslint/js";
import stylisticJs from '@stylistic/eslint-plugin-js'
/** @type {import('eslint').Linter.Config[]} */
export default [
{
files: ["src/**/*.js"],
ignores: [
"src/database/**/*"
],
languageOptions: {
globals: {
...globals.node
}
},
rules: {
"prefer-const": "warn",
"no-constant-binary-expression": "error",
"camelcase": "error",
"@stylistic/js/indent": ["error", 2],
"@stylistic/js/object-curly-spacing": ["error", "never"],
"@stylistic/js/quotes": ["error", "double"],
"no-console": "off"
},
plugins: {'@stylistic/js': stylisticJs}
},
];
这是我的 gitlab-ci.yml 文件:
image: node:latest
stages:
- install
- lint
- build
variables:
NODE_ENV: production
install:
stage: install
script:
- cd server
- npm ci
artifacts:
paths:
- server/node_modules/
eslint:
stage: lint
before_script:
- cd server
- npm ci
script:
- npm i -g eslint
- npm i -g globals
- npm run lint
allow_failure: false
build:
stage: build
script:
- cd server
- npm ci
- npm run build
dependencies:
- install
artifacts:
paths:
- server/dist/
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: always
我现在不知道该怎么办。如果您需要任何日志,请问我。
应该预运行推荐
npm install