Skip to content

Commit d06b60f

Browse files
committed
* fix `Parsing error: "parserOptions.programs" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided program instance(s):` by vuejs/vue-eslint-parser#104 (comment) * reset `languageOptions.parserOptions.ecmaVersion` to `latest` as it's set to `2018` by `pluginImportX.configs.recommended` - rules from `@typescript-eslint` for file `eslint.config.js` * simplify the importing of `vite.config.ts` * ignore files generated by yarn - rule `@typescript-eslint/no-throw-literal`: typescript-eslint/typescript-eslint#9083 @ eslint.config.js $ yarn eslint --fix @ fe
1 parent 0effb52 commit d06b60f

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

fe/eslint.config.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const rules = [{ // as of [email protected]
88
'unicorn/prevent-abbreviations': 'off',
99
'unicorn/consistent-function-scoping': 'off',
1010
'unicorn/filename-case': 'off',
11+
'unicorn/prefer-string-raw': 'off',
1112
},
1213
optin: {
1314
'unicorn/catch-error-name': ['error', { name: 'e' }],
@@ -283,8 +284,6 @@ const rules = [{ // as of [email protected]
283284
hoist: 'all',
284285
allow: ['name'],
285286
}],
286-
'no-throw-literal': 'off',
287-
'@typescript-eslint/no-throw-literal': 'error',
288287
'no-unused-expressions': 'off',
289288
'@typescript-eslint/no-unused-expressions': 'error',
290289
'no-use-before-define': 'off',
@@ -522,17 +521,17 @@ const rules = [{ // as of [email protected]
522521
}];
523522

524523
import viteConfig from './vite.config.ts';
524+
import pluginStylistic from '@stylistic/eslint-plugin';
525+
import pluginImportX from 'eslint-plugin-import-x';
526+
import pluginUnicorn from 'eslint-plugin-unicorn';
527+
import * as typescriptESLintParserForExtraFiles from 'typescript-eslint-parser-for-extra-files';
528+
import * as vueESLintParser from 'vue-eslint-parser';
529+
import vueESLintConfigTypescriptRecommendedExtends from '@vue/eslint-config-typescript/recommended.js';
530+
import pluginVue from 'eslint-plugin-vue';
525531
import { fixupConfigRules } from '@eslint/compat';
526532
import { FlatCompat } from '@eslint/eslintrc';
527533
import eslintJs from '@eslint/js';
528-
import * as vueESLintParser from 'vue-eslint-parser';
529-
import pluginVue from 'eslint-plugin-vue'
530-
import vueESLintConfigTypescriptRecommendedExtends from '@vue/eslint-config-typescript/recommended.js'
531-
import * as typescriptESLintParserForExtraFiles from 'typescript-eslint-parser-for-extra-files';
532-
import pluginStylistic from '@stylistic/eslint-plugin';
533534
import stylisticMigrate from '@stylistic/eslint-plugin-migrate';
534-
import pluginImportX from 'eslint-plugin-import-x';
535-
import pluginUnicorn from 'eslint-plugin-unicorn';
536535
import * as _ from 'lodash-es';
537536

538537
// https://github.com/eslint/eslint/issues/18093
@@ -553,6 +552,8 @@ export default [
553552
'plugin:@tanstack/eslint-plugin-query/recommended', // https://github.com/TanStack/query/pull/7253
554553
)),
555554
pluginUnicorn.configs['flat/recommended'],
555+
{ languageOptions: { parserOptions: { ecmaVersion: 'latest' } } },
556+
{ ignores: ['.yarn/', '.pnp.*'] },
556557
{ linterOptions: { reportUnusedDisableDirectives: 'error' } },
557558
{
558559
languageOptions: {
@@ -562,9 +563,15 @@ export default [
562563
},
563564
},
564565
plugins: { '@stylistic': pluginStylistic },
565-
566+
566567
// https://stackoverflow.com/questions/30221286/how-to-convert-an-array-of-objects-to-an-object-in-lodash/36692117#36692117
567-
rules: Object.assign({}, ..._.flatten(_.map(rules, Object.values))),
568+
rules: Object.assign({}, ..._.flatMap(rules, Object.values)),
569+
},
570+
{
571+
files: ['**/*.js'],
572+
languageOptions: { // https://github.com/vuejs/vue-eslint-parser/issues/104#issuecomment-2148652586
573+
parserOptions: { disallowAutomaticSingleRunInference: true },
574+
},
568575
},
569576
{
570577
files: ['**/*.ts'],
@@ -584,9 +591,7 @@ export default [
584591
settings: {
585592
'import-x/resolver': {
586593
typescript: true,
587-
588-
// https://github.com/pzmosquito/eslint-import-resolver-vite/issues/12#issuecomment-1979897899
589-
vite: { viteConfig: import('./vite.config') },
594+
vite: { viteConfig }, // https://github.com/pzmosquito/eslint-import-resolver-vite/issues/12#issuecomment-2148676875
590595
},
591596
},
592597
},
@@ -598,6 +603,10 @@ export default [
598603
'@stylistic/migrate/migrate-ts': 'error',
599604
'@stylistic/comma-dangle': ['error', 'always-multiline'],
600605
'@typescript-eslint/naming-convention': 'off',
606+
'@typescript-eslint/no-unsafe-call': 'off',
607+
'@typescript-eslint/no-unsafe-argument': 'off',
608+
'@typescript-eslint/no-unsafe-assignment': 'off',
609+
'@typescript-eslint/no-unsafe-member-access': 'off',
601610
},
602611
},
603612
];

fe/src/views/Post.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ useHead({
6868
6969
const forumName = `${firstPostPage.forum.name}吧`;
7070
const threadTitle = firstPostPage.threads[0].title;
71-
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
71+
7272
switch (queryFormRef.value?.getCurrentQueryType()) {
7373
case 'fid':
7474
case 'search':

0 commit comments

Comments
 (0)