CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-nuxt--eslint-config

ESLint config for Nuxt projects with flat config support and extensive customization options

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

configuration-options.mddocs/

Configuration Options

Comprehensive type system for configuring all aspects of the ESLint setup, from feature toggles to formatting options.

Capabilities

Formatter Options

Configuration for file formatters supporting multiple tools and file types.

interface OptionsFormatters {
  /**
   * Enable formatting support for CSS, Less, Sass, and SCSS.
   * Currently only supports Prettier.
   */
  css?: 'prettier' | boolean;

  /**
   * Enable formatting support for HTML.
   * Currently only supports Prettier.
   */
  html?: 'prettier' | boolean;

  /**
   * Enable formatting support for XML.
   * Currently only supports Prettier.
   */
  xml?: 'prettier' | boolean;

  /**
   * Enable formatting support for SVG.
   * Currently only supports Prettier.
   */
  svg?: 'prettier' | boolean;

  /**
   * Enable formatting support for Markdown.
   * Support both Prettier and dprint.
   * When set to true, it will use Prettier.
   */
  markdown?: 'prettier' | 'dprint' | boolean;

  /**
   * Enable formatting support for GraphQL.
   */
  graphql?: 'prettier' | boolean;

  /**
   * Custom options for Prettier.
   * By default it's controlled by our own config.
   */
  prettierOptions?: any;

  /**
   * Custom options for dprint.
   * By default it's controlled by our own config.
   */
  dprintOptions?: boolean;
}

Usage Examples:

import { createConfigForNuxt } from "@nuxt/eslint-config";

// Enable all formatters with Prettier
export default createConfigForNuxt({
  features: {
    formatters: {
      css: true,
      html: true,
      xml: true,
      svg: true,
      markdown: "prettier",
      graphql: true
    }
  }
});

// Mixed formatter configuration
export default createConfigForNuxt({
  features: {
    formatters: {
      css: "prettier",
      html: "prettier",
      markdown: "dprint", // Use dprint for markdown
      prettierOptions: {
        printWidth: 100,
        singleQuote: true,
        trailingComma: "es5"
      }
    }
  }
});

// Enable formatters with boolean shorthand
export default createConfigForNuxt({
  features: {
    formatters: true // Enables CSS, HTML, GraphQL with Prettier; SVG/XML if @prettier/plugin-xml is available
  }
});

Stylistic Customization Options

Configuration for stylistic rules and formatting preferences, integrated with @stylistic/eslint-plugin.

/**
 * Stylistic customization options from @stylistic/eslint-plugin
 * Controls code formatting and style preferences
 */
interface StylisticCustomizeOptions {
  /**
   * Indentation configuration
   * @default 2
   */
  indent?: number | 'tab';
  
  /**
   * Quote style preference
   * @default 'single'
   */
  quotes?: 'single' | 'double';
  
  /**
   * Semicolon usage
   * @default false
   */
  semi?: boolean;
  
  /**
   * Additional stylistic options
   */
  [key: string]: any;
}

Usage Examples:

// Custom stylistic configuration
export default createConfigForNuxt({
  features: {
    stylistic: {
      indent: 4,
      quotes: "double",
      semi: true
    }
  }
});

// Tab-based indentation
export default createConfigForNuxt({
  features: {
    stylistic: {
      indent: "tab",
      quotes: "single",
      semi: false
    }
  }
});

// Enable with defaults
export default createConfigForNuxt({
  features: {
    stylistic: true // Uses: indent: 2, quotes: 'single', semi: false
  }
});

Resolved Configuration Type

The internal resolved configuration type with all defaults applied and required fields populated.

interface NuxtESLintConfigOptionsResolved {
  /** Resolved feature configuration with all defaults applied */
  features: Required<NotNill<NuxtESLintFeaturesOptions>>;
  /** Resolved directory configuration with all defaults applied */
  dirs: Required<NotNill<DirectoriesConfig>>;
}

/**
 * Utility type that excludes null and undefined
 */
type NotNill<T> = T extends null | undefined ? never : T;

Awaitable Type

Generic utility type for handling synchronous and asynchronous values.

/**
 * Type that can be a value or promise of that value
 */
type Awaitable<T> = T | Promise<T>;

Usage Examples:

// Function that accepts both sync and async configs
function processConfig(config: Awaitable<ESLintConfig>) {
  // Handle both sync and async cases
  return Promise.resolve(config).then(resolvedConfig => {
    // Process the resolved config
    return resolvedConfig;
  });
}

// Using with different input types
processConfig({ rules: { "no-console": "warn" } }); // Sync
processConfig(import("./config.js")); // Async

Default Resolution Behavior

Understanding how configuration options are resolved and defaults are applied.

// Default values applied during resolution:
const defaults = {
  features: {
    standalone: true,
    stylistic: false,
    typescript: isPackageExists('typescript'), // Auto-detected
    tooling: false,
    formatters: false,
    nuxt: {},
    import: {}
  },
  dirs: {
    root: ['.', './app'], // Support both Nuxt 3 and 4 conventions
    src: [], // Defaults to root directories
    pages: [], // Defaults to src/pages for each src directory
    layouts: [], // Defaults to src/layouts for each src directory
    // ... other directories follow the same pattern
  }
};

Usage Examples:

// Minimal config - uses all defaults
export default createConfigForNuxt();

// Partial config - merges with defaults
export default createConfigForNuxt({
  features: {
    typescript: { strict: true } // Only override specific options
  },
  dirs: {
    src: ["./src"] // Override specific directories
  }
});

// Understanding directory resolution
export default createConfigForNuxt({
  dirs: {
    root: ["./app"],
    src: ["./app"] // Will generate pages: ["./app/pages"], components: ["./app/components"], etc.
  }
});

Install with Tessl CLI

npx tessl i tessl/npm-nuxt--eslint-config

docs

configuration-options.md

core-configuration.md

flat-config-utilities.md

index.md

utility-functions.md

tile.json