Skip to content

Bug: @typescript-eslint/ban-ts-comment <context.sourceCode.getAllComments is not a function on html> #11300

Closed as not planned
@6aKa

Description

@6aKa

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

http://none.com

Repro Code

empty or not empty html file

ESLint Config

import { defineConfig, globalIgnores } from 'eslint/config';
import type { Linter } from 'eslint';
import css from '@eslint/css';
import globals from 'globals';
import html from '@html-eslint/eslint-plugin';
import js from '@eslint/js';
import json from '@eslint/json';
import markdown from '@eslint/markdown';
import tailwind from 'eslint-plugin-tailwindcss';
import tseslint from 'typescript-eslint';

export default defineConfig([
  globalIgnores(['**/static_dependencies/*']),
  {
    files: ['**/*.{js,mjs,cjs,ts,tsx}'],
    plugins: { js },
    extends: ['js/recommended']
  },
  {
    files: ['**/*.{js,mjs,cjs,ts,tsx}'],
    languageOptions: { globals: { ...globals.browser, ...globals.node } }
  },
  ...(tseslint.configs.recommended as Linter.Config[]),
  ...tailwind.configs['flat/recommended'],
  {
    files: ['**/*.json'],
    plugins: { json },
    language: 'json/json',
    extends: ['json/recommended']
  },
  {
    files: ['**/*.jsonc'],
    plugins: { json },
    language: 'json/jsonc',
    extends: ['json/recommended']
  },
  {
    files: ['**/*.json5'],
    plugins: { json },
    language: 'json/json5',
    extends: ['json/recommended']
  },
  {
    files: ['**/*.md'],
    plugins: { markdown },
    language: 'markdown/commonmark',
    extends: ['markdown/recommended']
  },
  {
    files: ['**/*.css'],
    plugins: { css },
    language: 'css/css',
    extends: ['css/recommended']
  },
  {
    files: ['**/*.html'],
    plugins: { html },
    language: 'html/html'
  },
  {
    files: ['**/*.ts', '**/*.tsx'],
    rules: {
      // "@typescript-eslint/no-explicit-any": "off",
      '@typescript-eslint/no-unused-vars': [
        'error',
        {
          args: 'all',
          argsIgnorePattern: '^_',
          caughtErrors: 'all',
          caughtErrorsIgnorePattern: '^_',
          destructuredArrayIgnorePattern: '^_',
          vars: 'all',
          varsIgnorePattern: '^_'
        }
      ],
      'sort-imports': [
        'error',
        {
          ignoreCase: false,
          ignoreDeclarationSort: false,
          ignoreMemberSort: false,
          memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
          allowSeparatedGroups: true
        }
      ]
    }
  }
]);

tsconfig

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "noEmit": true
  },
  "include": ["ts/src"]
}

Expected Result

linting

Actual Result

eslint --config ../../eslint.config.ts src/templates/about.html
Oops! Something went wrong! :(

ESLint: 9.28.0

TypeError: context.sourceCode.getAllComments is not a function. (In 'context.sourceCode.getAllComments()', 'context.sourceCode.getAllComments' is undefined)
Occurred while linting /Users/baka/Projects/DEUSEX/briareos/apps/server/src/templates/about.html:1
Rule: "@typescript-eslint/ban-ts-comment"
    at Program (/Users/baka/Projects/DEUSEX/briareos/node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js:119:53)
    at ruleErrorHandler (/Users/baka/Projects/DEUSEX/briareos/node_modules/eslint/lib/linter/linter.js:1307:33)
    at forEach (native:1:11)
    at emit (/Users/baka/Projects/DEUSEX/briareos/node_modules/eslint/lib/linter/safe-emitter.js:45:26)
    at #applySelector (/Users/baka/Projects/DEUSEX/briareos/node_modules/eslint/lib/linter/source-code-traverser.js:148:17)
    at applySelectors (/Users/baka/Projects/DEUSEX/briareos/node_modules/eslint/lib/linter/source-code-traverser.js:206:10)
    at traverseSync (/Users/baka/Projects/DEUSEX/briareos/node_modules/eslint/lib/linter/source-code-traverser.js:277:16)
    at runRules (/Users/baka/Projects/DEUSEX/briareos/node_modules/eslint/lib/linter/linter.js:1348:12)
    at #flatVerifyWithoutProcessors (/Users/baka/Projects/DEUSEX/briareos/node_modules/eslint/lib/linter/linter.js:2252:22)
    at verify (/Users/baka/Projects/DEUSEX/briareos/node_modules/eslint/lib/linter/linter.js:1808:10)

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfix: user errorissue was fixed by correcting the configuration / correcting the codelocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginworking as intendedIssues that are closed as they are working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy