ESLint 仅在本地运行(不是 github 操作)。忽略patternt和src模式冲突

问题描述 投票:0回答:1
这似乎是一个奇怪的错误,我相当确定我没有任何 eslint 忽略目录规则,而且实际上我在本地计算机上的 CLI 和 vscode 中都有问题目录中的 eslint 问题。我想,如果我实际上要忽略目录的某些子目录,那么 github 操作的解决方案将是不考虑推送损坏。 GitHub Actions 错误消息:

> npx eslint src/** *.{js,jsx,ts,tsx} --fix Oops! Something went wrong! :( ESLint: 8.57.0 You are linting "src/api", but all of the files matching the glob pattern "src/api" are ignored. If you don't want to lint these files, remove the pattern "src/api" from the list of arguments passed to ESLint.
工作流程:

name: GitHub Actions Demo run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 on: push: branches: - deploy jobs: everything: runs-on: ubuntu-latest # container: # image: cypress/included steps: - name: Checkout uses: actions/checkout@v4 - name: Cypress install uses: cypress-io/github-action@v6 with: # Disable running of tests within install job runTests: false build: npm install - name: Cypress run uses: cypress-io/github-action@v6 with: start: npm run dev - name: Run ESLint run: npm run lint - name: Update Schema run: npm run updateSchema - name: deploy uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}

No any ignore rules package.json or files for ignoring them

import globals from "globals"; import pluginJs from "@eslint/js"; import tseslint from "typescript-eslint"; import eslintPluginUnicorn from "eslint-plugin-unicorn"; import eslintConfigPrettier from "eslint-config-prettier"; export default [ {languageOptions: { globals: globals.browser }}, pluginJs.configs.recommended, eslintPluginUnicorn.configs['flat/recommended'], // ...tseslint.configs.recommended, // ...tseslint.configs.recommendedTypeChecked, { languageOptions: { globals: globals.browser, parserOptions: { project: true, // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment tsconfigRootDir: import.meta.dirname, }, }, rules: { // "@typescript-eslint/no-floating-promises": "error", "unicorn/filename-case": [ "error", { case: "camelCase", }, ], }, }, // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access // pluginJs.configs.recommended, // // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access // eslintPluginUnicorn.configs["flat/recommended"], // // //...tseslint.configs.recommended, // // ...tseslint.configs.recommendedTypeChecked, // eslintConfigPrettier, ];
    
github-actions eslint
1个回答
0
投票
我看到三个更改可能会修复您遇到的错误。

1/ 修改

package.json

  • lint
    脚本中有一个拼写错误:
    ** *
    而不是
    **/*
    
    
  • 明确提供
  • eslint.config.mjs
     文件的路径,以防止特定环境(包括您的编辑器)可能具有您不知道的某些全局覆盖的任何不确定行为。
{ "lint": "eslint eslint.config.mjs src/**/*.{js,jsx,ts,tsx} --fix", }
2/
仔细检查以确保您的 

tsconfig.json

 也包含 lint 范围内的所有文件。 tsconfig 范围
必须比您的 lint 范围更宽。

例如:

{ "include": [ "./src/**/*.js", "./src/**/*.jsx", "./src/**/*.ts", "./src/**/*.tsx", "./eslint.config.mjs" ] }
    
© www.soinside.com 2019 - 2024. All rights reserved.