Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1743

eslint:languages:js TSError: Unexpected keyword or identifier

$
0
0

I’m encountering an issue with ESLint and TypeScript in my project.

When running the following ESLint command:

pnpm eslint src/lib/components/SEO.svelte --debug

I get the following error:

  ...  eslint:eslint Lint /home/seba/project/src/lib/components/SEO.svelte +831ms  eslint:linter Linting code for /home/seba/project/src/lib/components/SEO.svelte (pass 1) +0ms  eslint:linter Verify +0ms  eslint:linter With flat config: /home/seba/project/src/lib/components/SEO.svelte +0ms  eslint:linter Apply the processor: { meta: { name: 'eslint-plugin-svelte', version: '2.46.1' }, supportsAutofix: true, preprocess: [Function: preprocess], postprocess: [Function: postprocess] } +0ms  eslint:linter A code block was found: '(unnamed)'+2ms  eslint:languages:js Parsing: /home/seba/project/src/lib/components/SEO.svelte +0ms  eslint:languages:js Unexpected keyword or identifier.  eslint:languages:js TSError: Unexpected keyword or identifier.    at createError (/home/seba/project/node_modules/.pnpm/@typescript-eslint+typescript-estree@8.23.0_typescript@5.7.3/node_modules/@typescript-eslint/typescript-estree/dist/node-utils.js:572:12)    at convertError (/home/seba/project/node_modules/.pnpm/@typescript-eslint+typescript-estree@8.23.0_typescript@5.7.3/node_modules/@typescript-eslint/typescript-estree/dist/convert.js:51:41)    at astConverter (/home/seba/project/node_modules/.pnpm/@typescript-eslint+typescript-estree@8.23.0_typescript@5.7.3/node_modules/@typescript-eslint/typescript-estree/dist/ast-converter.js:15:42)    at parseAndGenerateServices (/home/seba/project/node_modules/.pnpm/@typescript-eslint+typescript-estree@8.23.0_typescript@5.7.3/node_modules/@typescript-eslint/typescript-estree/dist/parser.js:162:66)    at Object.parseForESLint (/home/seba/project/node_modules/.pnpm/@typescript-eslint+parser@8.23.0_eslint@9.20.0_jiti@2.4.2__typescript@5.7.3/node_modules/@typescript-eslint/parser/dist/parser.js:101:80)    at parseScriptWithoutAnalyzeScope (/home/seba/project/node_modules/.pnpm/svelte-eslint-parser@0.43.0_svelte@5.19.9/node_modules/svelte-eslint-parser/lib/parser/script.js:49:18)    at analyzeTypeScriptInSvelte (/home/seba/project/node_modules/.pnpm/svelte-eslint-parser@0.43.0_svelte@5.19.9/node_modules/svelte-eslint-parser/lib/parser/typescript/analyze/index.js:19:64)    at parseTypeScriptInSvelte (/home/seba/project/node_modules/.pnpm/svelte-eslint-parser@0.43.0_svelte@5.19.9/node_modules/svelte-eslint-parser/lib/parser/typescript/index.js:12:59)    at parseAsSvelte (/home/seba/project/node_modules/.pnpm/svelte-eslint-parser@0.43.0_svelte@5.19.9/node_modules/svelte-eslint-parser/lib/parser/index.js:48:52)    at Object.parseForESLint (/home/seba/project/node_modules/.pnpm/svelte-eslint-parser@0.43.0_svelte@5.19.9/node_modules/svelte-eslint-parser/lib/parser/index.js:37:12) +48ms  eslint:linter Generating fixed text for /home/seba/project/src/lib/components/SEO.svelte (pass 1) +49ms  eslint:source-code-fixer Applying fixes +0ms  eslint:source-code-fixer shouldFix parameter was false, not attempting fixes +0ms/home/seba/project/src/lib/components/SEO.svelte  19:44  error  Parsing error: Unexpected keyword or identifier✖ 1 problem (1 error, 0 warnings)

This is my eslint.config.js:

import prettier from 'eslint-config-prettier';import js from '@eslint/js';import { includeIgnoreFile } from '@eslint/compat';import svelte from 'eslint-plugin-svelte';import globals from 'globals';import { fileURLToPath } from 'node:url';import ts from 'typescript-eslint';const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));export default ts.config(    includeIgnoreFile(gitignorePath),    js.configs.recommended,    ...ts.configs.recommended,    ...svelte.configs['flat/recommended'],    prettier,    ...svelte.configs['flat/prettier'],    {        languageOptions: {            globals: {                ...globals.browser,                ...globals.node,            },        },    },    {        files: ['**/*.svelte'],        languageOptions: {            parserOptions: {                parser: ts.parser,            },        },    },    {        rules: {'no-unused-vars': 'off','@typescript-eslint/no-unused-vars': ['warn',                {                    argsIgnorePattern: '^_[^_].*$|^_$',                    varsIgnorePattern: '^_[^_].*$|^_$',                    caughtErrorsIgnorePattern: '^_[^_].*$|^_$',                },            ],        },    },);

And this is my SEO.svelte component (located at src/lib/components/SEO.svelte):

    import type { Language, Locale } from '$lib/i18n';    type Props = { locale: Locale['seo']; lang: Language; page: keyof Locale['seo'] };    const { locale, lang, page }: Props = $props();    const ld = {'@context': 'https://schema.org','@type': 'Organization',        name: 'aid-ly',        url: `https://aid-ly.org/${lang}/`,        logo: 'https://aid-ly.org/logo.svg',        description: locale[page].description,    };</script><svelte:head><!-- eslint-disable-next-line svelte/no-at-html-tags -->    {@html `<script type="application/ld+json">${JSON.stringify(ld)}</script>`}</svelte:head>

It seems like the error might be related to the " at the end of the type property in my SEO.svelte file.

Has anyone experienced this issue or know how to resolve it? Any help would be appreciated!


Viewing all articles
Browse latest Browse all 1743

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>