te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>typescript - "All arguments must be objects" error when running eslint - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

typescript - "All arguments must be objects" error when running eslint - Stack Overflow

programmeradmin3浏览0评论

I need to run eslint on a script in my_repo, but I am totally unfamiliar with TypeScript, so I might be doing some lame mistake.

This is the repo structure, with the eslint.config.mjs configuration file:

my_repo
-- frontend_react
---- eslint.config.mjs
---- path_to_script

so I installed it and ran it:

npm install eslint --save-dev  -> it installs eslint 9.20.1
npx eslint --config frontend_react/eslint.config.mjs frontend_react/src/views/tmp/StreamsReporting/StreamsStatistics.tsx --fix

but I'm getting the error:

Oops! Something went wrong! :(

ESLint: 9.0.0

ConfigError: Config (unnamed): All arguments must be objects.
    at rethrowConfigError (/Users/user_name/work/projects/my_repo/node_modules/@humanwhocodes/config-array/api.js:225:8)
    at /Users/user_name/work/projects/my_repo/node_modules/@humanwhocodes/config-array/api.js:1018:5
    at Array.reduce (<anonymous>)
    at FlatConfigArray.getConfig (/Users/user_name/work/projects/my_repo/node_modules/@humanwhocodes/config-array/api.js:1014:39)
    at FlatConfigArray.isFileIgnored (/Users/user_name/work/projects/my_repo/node_modules/@humanwhocodes/config-array/api.js:1046:15)
    at /Users/user_name/work/projects/my_repo/node_modules/eslint/lib/eslint/eslint-helpers.js:514:38
    at Array.forEach (<anonymous>)
    at findFiles (/Users/user_name/work/projects/my_repo/node_modules/eslint/lib/eslint/eslint-helpers.js:503:11)
    at async ESLint.lintFiles (/Users/user_name/work/projects/my_repo/node_modules/eslint/lib/eslint/eslint.js:846:27)
    at async Object.execute (/Users/user_name/work/projects/my_repo/node_modules/eslint/lib/cli.js:461:23) 

The configuration file is:

import prettier from 'eslint-plugin-prettier';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
  baseDirectory: __dirname,
  recommendedConfig: js.configs.recommended,
  allConfig: js.configs.all,
});

export default [
  {
    ignores: ['**/node_modules', '**/package.lock.json', '**/build', '**/resources', '**/vite.config.js'],
  },
  ..pat.extends('eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'prettier'),
  {
    plugins: {
      prettier,
      '@typescript-eslint': typescriptEslint,
    },

    languageOptions: {
      globals: {
        ...globals.browser,
      },

      parser: tsParser,
      ecmaVersion: 'latest',
      sourceType: 'module',

      parserOptions: {
        project: ['tsconfig.json'],
      },
    },

    rules: {
      'react/react-in-jsx-scope': 'off',
      'prettier/prettier': ['error'],
      'semi': ['error', 'always'],

      'quotes': [
        'warn',
        'single',
        {
          allowTemplateLiterals: true,
        },
      ],

      'no-extra-boolean-cast': 'off',
    },
  },
];

I tried changing the first part to:

const extendsConfig = compat.extends(
  'eslint:recommended',
  'plugin:@typescript-eslint/eslint-recommended',
  'plugin:@typescript-eslint/recommended',
  'prettier'
);

export default {
  ignores: ['**/node_modules', '**/package.lock.json', '**/build', '**/resources', '**/vite.config.js'],
  extends: extendsConfig,

[...]

but now it seems the file is ignored altogether:

/Users/user_name/work/projects/my_repo/frontend_react/src/views/tmp/StreamsReporting/StreamsStatistics.tsx
  0:0  warning  File ignored because no matching configuration was supplied

✖ 1 problem (0 errors, 1 warning)

Any suggestions?

发布评论

评论列表(0)

  1. 暂无评论