CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-modern-js--eslint-config

ESLint configuration package for Modern.js projects with TypeScript, type-checking, and Node.js support

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

@modern-js/eslint-config

@modern-js/eslint-config provides comprehensive ESLint configuration for Modern.js projects with TypeScript support, type-aware linting, Prettier integration, and Node.js-specific rules. It serves as a centralized ESLint configuration package within the Modern.js ecosystem, extending base configurations with additional features for modern JavaScript/TypeScript development.

Package Information

  • Package Name: @modern-js/eslint-config
  • Package Type: npm
  • Language: JavaScript (CommonJS)
  • Installation: npm install @modern-js/eslint-config (requires Modern.js workspace environment)

Core Imports

// Main configuration (full-featured with type checking)
const config = require('@modern-js/eslint-config');

// Lite configuration (without type checking)
const liteConfig = require('@modern-js/eslint-config/lite');

// Node.js specific configuration (typically used internally)
const nodeConfig = require('@modern-js/eslint-config/eslintrc.node');

// Jest configuration for testing environments
const jestConfig = require('@modern-js/eslint-config/jest.config');

Basic Usage

The most common usage is to extend one of the configurations in your ESLint configuration file:

// .eslintrc.js
module.exports = {
  extends: ['@modern-js/eslint-config'],
  // Your custom rules here
};

For lighter configuration without type checking:

// .eslintrc.js
module.exports = {
  extends: ['@modern-js/eslint-config/lite'],
  // Your custom rules here
};

Architecture

@modern-js/eslint-config is built as a layered configuration system:

  • Base Layer: Extends @modern-js-app/eslint-config for core JavaScript/TypeScript rules
  • Type Layer: Adds TypeScript type-aware linting (main config only)
  • Node.js Layer: Adds Node.js-specific environment settings and rules
  • Prettier Layer: Integrates with Prettier for consistent code formatting

Note: This package depends on @modern-js-app/eslint-config, which is an internal workspace dependency within the Modern.js monorepo. For standalone usage, you would need access to the complete Modern.js workspace or its published dependencies.

The package uses a composition approach where each configuration variant combines different layers to provide targeted rule sets for different use cases.

Capabilities

Main Configuration

Complete ESLint configuration with full TypeScript support, type-aware linting, Prettier integration, and Node.js-specific rules.

/**
 * Main ESLint configuration export
 * Includes: base rules, TypeScript, type checking, Prettier, Node.js rules
 */
module.exports = {
  extends: [
    '@modern-js-app/eslint-config/base',
    '@modern-js-app/eslint-config/ts', 
    '@modern-js-app/eslint-config/ts.withType',
    '@modern-js-app/eslint-config/prettier',
    './eslintrc.node.js'
  ]
};

Usage:

// .eslintrc.js
module.exports = {
  extends: ['@modern-js/eslint-config']
};

Lite Configuration

Lighter ESLint configuration without type-aware linting, suitable for faster linting in development or CI environments.

/**
 * Lite ESLint configuration export
 * Includes: base rules, TypeScript (no type checking), Prettier, Node.js rules
 */
module.exports = {
  extends: [
    '@modern-js-app/eslint-config/base',
    '@modern-js-app/eslint-config/ts',
    '@modern-js-app/eslint-config/prettier', 
    './eslintrc.node.js'
  ]
};

Usage:

// .eslintrc.js for faster linting
module.exports = {
  extends: ['@modern-js/eslint-config/lite']
};

Node.js Configuration

Node.js-specific ESLint rules and environment configuration, typically used as part of the main and lite configurations but can be used standalone.

/**
 * Node.js-specific ESLint configuration
 * Includes: Node.js environment, import resolver, Node.js plugin rules
 */
module.exports = {
  env: {
    commonjs: false,
    browser: false,
    node: true
  },
  settings: { 
    'import/resolver': 'node' 
  },
  rules: {
    // Node.js specific rules
    'node/no-unsupported-features/es-builtins': 2,
    'node/no-unsupported-features/es-syntax': 0,
    'node/no-unsupported-features/node-builtins': 2,
    'node/prefer-global/url': [2, 'never'],
    'node/prefer-global/url-search-params': [2, 'never'],
    'node/prefer-global/buffer': [2, 'never'],
    'node/prefer-global/text-decoder': [2, 'never'],
    'node/prefer-global/text-encoder': [2, 'never'],
    'node/process-exit-as-throw': 2,
    'node/no-deprecated-api': 2,
    'node/prefer-promises/dns': 2,
    'node/prefer-promises/fs': 0,
    'filenames/match-regex': 0,
    'import/default': 0,
    'import/no-dynamic-require': 0,
    'import/no-unused-modules': 0,
    'import/no-commonjs': 0
  },
  overrides: [
    {
      files: ['*.ts', '*.d.ts', '*.tsx'],
      settings: {
        'import/external-module-folders': ['node_modules', 'node_modules/@types'],
        'import/parsers': {
          '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts']
        },
        'import/resolver': { 
          node: { extensions: jsExtensions } // References @modern-js-app/eslint-config/utils
        }
      },
      rules: {
        'import/named': 'off',
        'node/no-unsupported-features/es-syntax': 0,
        '@typescript-eslint/no-var-requires': 0,
        '@typescript-eslint/no-require-imports': 0
      }
    }
  ]
};

Usage:

// Standalone Node.js configuration
module.exports = {
  extends: ['@modern-js/eslint-config/eslintrc.node']
};

Types

ESLint Configuration Object

/**
 * Standard ESLint configuration object structure
 * All exports return this format
 */
interface ESLintConfig {
  extends?: string[];           // Extended configurations
  env?: {                      // Environment settings
    [key: string]: boolean;
  };
  settings?: {                 // Plugin settings
    [key: string]: any;
  };
  rules?: {                    // ESLint rules
    [ruleName: string]: any;
  };
  overrides?: {                // File-specific overrides
    files: string[];
    settings?: { [key: string]: any };
    rules?: { [ruleName: string]: any };
  }[];
}

Jest Configuration

Jest-specific testing configuration that extends shared Jest configuration from the Modern.js build scripts.

/**
 * Jest configuration for testing environments
 * Extends shared configuration with package-specific settings
 */
const sharedConfig = require('@scripts/jest-config');

module.exports = {
  ...sharedConfig,
  rootDir: __dirname
};

Usage:

// jest.config.js
module.exports = require('@modern-js/eslint-config/jest.config');

Configuration Variants Comparison

FeatureMain ConfigLite ConfigNode.js ConfigJest Config
Base Rules
TypeScriptOverride only
Type Checking
Prettier
Node.js Rules
Jest Support
PerformanceSlowerFasterFastestFast
Use CaseFull lintingDevelopment/CINode.js onlyTesting

docs

index.md

tile.json