How to Lint TypeScript Code with ESLint in the iptv-org/iptv Repository

The iptv-org/iptv repository uses ESLint with @typescript-eslint and @stylistic plugins configured in eslint.config.mjs to enforce code quality and consistent style across TypeScript files in the scripts/ and tests/ directories.

Maintaining code quality in open-source projects requires automated tooling to catch errors early and enforce consistent style. The iptv-org/iptv repository implements a robust linting setup that combines ESLint's flat config format with TypeScript-specific rules to validate its automation scripts and test suites.

ESLint Configuration Architecture

The linting setup centers on eslint.config.mjs, which defines how ESLint processes TypeScript files using the modern flat configuration format.

Base Configuration and Parser

The configuration uses FlatCompat to bridge legacy ESLint presets with the new flat config system. It extends eslint:recommended and plugin:@typescript-eslint/recommended to establish baseline rules for JavaScript and TypeScript code.

The @typescript-eslint/parser handles TypeScript syntax parsing, configured with ecmaVersion: 'latest' and sourceType: 'module' to match the project's tsconfig.json settings. The parser automatically reads TypeScript compiler options from tsconfig.json, ensuring ESLint understands the project's module resolution and type checking configuration.

Plugins and Stylistic Rules

The setup integrates two primary plugins:

  • @typescript-eslint: Provides TypeScript-specific linting rules
  • @stylistic: Enforces code formatting standards including indentation, line endings, and quote styles

The configuration in eslint.config.mjs overrides default rules to match the project's coding standards:

  • 2-space indentation enforced via @stylistic/indent
  • Windows line endings (CRLF) required through @stylistic/linebreak-style
  • Single quotes mandated for strings via @stylistic/quotes
  • No semicolons enforced through @stylistic/semi

The configuration explicitly ignores test data files located in tests/__data__/ to prevent linting errors in fixture files.

Running ESLint on TypeScript Files

The package.json defines an npm script that executes ESLint across the project's TypeScript and JavaScript source files.

Basic Linting Command

Run the full linting suite across scripts/ and tests/ directories:

npm run lint

This executes the equivalent command:

npx eslint "scripts/**/*.{ts,js}" "tests/**/*.{ts,js}"

ESLint processes all .ts and .js files in these directories, reporting any violations of the configured rules.

Auto-Fixing Linting Issues

Many style violations can be automatically corrected. Run the fix command to resolve issues without manual intervention:

npm run lint -- --fix

Or execute directly with npx:

npx eslint "scripts/**/*.{ts,js}" "tests/**/*.{ts,js}" --fix

This command modifies files to comply with rules such as indentation, quote style, and semicolon usage.

Key Configuration Files

Understanding the relationship between these files helps when modifying linting behavior:

  • eslint.config.mjs: The primary ESLint configuration using the flat config format. Defines parsers, plugins, rules, and ignore patterns.
  • package.json: Contains the lint npm script and declares dependencies including eslint, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, and @stylistic/eslint-plugin.
  • tsconfig.json: TypeScript compiler configuration that ESLint reads via @typescript-eslint/parser to understand module resolution and type checking settings.

Summary

  • The iptv-org/iptv repository uses ESLint with TypeScript support via @typescript-eslint/parser and @typescript-eslint/eslint-plugin.
  • Configuration resides in eslint.config.mjs using the modern flat config format with FlatCompat for legacy preset support.
  • The @stylistic plugin enforces specific formatting rules including 2-space indentation, Windows line endings, single quotes, and no semicolons.
  • Run npm run lint to check all TypeScript files in scripts/ and tests/ directories, or add --fix to automatically correct style violations.

Frequently Asked Questions

How do I run ESLint on specific files instead of the entire codebase?

Use npx with specific file paths rather than the npm script. For example, to lint only scripts/utils.ts, run npx eslint scripts/utils.ts. You can also target specific directories by adjusting the glob patterns, such as npx eslint "scripts/core/**/*.ts" to lint only the core subdirectory.

Why does the configuration use Windows line endings instead of Unix?

The @stylistic/linebreak-style rule in eslint.config.mjs explicitly enforces Windows-style CRLF line endings across the codebase. This standardizes the repository for contributors working on Windows systems and ensures consistent line ending behavior regardless of the operating system used by individual developers.

Can I disable specific ESLint rules for test files?

Yes, you can modify eslint.config.mjs to add override configurations for specific file patterns. While the current configuration only ignores tests/__data__/, you could add an object with files: ["tests/**/*.ts"] and a rules section that disables specific TypeScript rules for test files, or set env: { jest: true } if using Jest.

What should I do if ESLint reports parser errors for experimental TypeScript syntax?

Ensure your tsconfig.json includes the necessary compiler options for the experimental features, as @typescript-eslint/parser reads this configuration. If the parser still fails, you may need to update the @typescript-eslint packages to versions that support the specific TypeScript syntax, or temporarily disable the specific rule causing the error in eslint.config.mjs.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →