CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-stylistic--eslint-plugin-js

JavaScript stylistic rules for ESLint that enforce code formatting and style consistency without changing code logic.

Pending
Overview
Eval results
Files

plugin-configuration.mddocs/

Plugin Configuration

This document covers the main plugin object and configuration presets provided by @stylistic/eslint-plugin-js.

Plugin Object

The main export is an ESLint plugin object containing all 70 stylistic rules and pre-built configuration presets.

interface Plugin {
  rules: Rules;
  configs: {
    'disable-legacy': Linter.Config;
    'all': Linter.Config;
    'all-flat': Linter.Config;
  };
}

declare const plugin: Plugin;
export default plugin;

Usage Example

import stylisticJs from '@stylistic/eslint-plugin-js';

export default [
  {
    plugins: {
      '@stylistic/js': stylisticJs
    },
    rules: {
      '@stylistic/js/indent': ['error', 2],
      '@stylistic/js/semi': ['error', 'always']
    }
  }
];

Configuration Presets

configs.all

Enables all 70 stylistic rules with their default/recommended settings. This configuration uses the flat config format and is ideal for projects that want comprehensive stylistic enforcement.

const all: Linter.Config;

Usage:

import stylisticJs from '@stylistic/eslint-plugin-js';

export default [
  stylisticJs.configs.all
];

configs['disable-legacy']

Disables all 70 legacy ESLint core stylistic rules that conflict with this plugin's rules. This prevents rule conflicts when migrating from ESLint core stylistic rules to @stylistic rules. Works with both flat and legacy config formats.

Important: Use this config when you want to avoid "Definition for rule was not found" errors from deprecated ESLint core rules.

const disableLegacy: Linter.Config;

Usage:

import stylisticJs from '@stylistic/eslint-plugin-js';

export default [
  stylisticJs.configs['disable-legacy'],
  // your other configs...
];

configs['all-flat'] (Deprecated)

Alias for configs.all. Use configs.all instead.

const allFlat: Linter.Config; // @deprecated use 'all' instead

Individual Rule Access

All 70 rules are available through the rules object or as individual exports from their respective paths:

// Through plugin object
const indentRule = stylisticJs.rules.indent;
const quotesRule = stylisticJs.rules.quotes;

// As individual imports (all 70 rules available)
import indentRule from '@stylistic/eslint-plugin-js/rules/indent';
import quotesRule from '@stylistic/eslint-plugin-js/rules/quotes';
import semiRule from '@stylistic/eslint-plugin-js/rules/semi';
import arrayBracketSpacing from '@stylistic/eslint-plugin-js/rules/array-bracket-spacing';
// ... pattern continues for all 70 rules

Available individual rule exports (all follow the pattern @stylistic/eslint-plugin-js/rules/{rule-name}):

  • Array rules: array-bracket-newline, array-bracket-spacing, array-element-newline
  • Function rules: function-call-spacing, function-paren-newline, space-before-function-paren
  • Object rules: object-curly-spacing, object-curly-newline, object-property-newline
  • Spacing rules: indent, space-before-blocks, space-infix-ops, keyword-spacing
  • Punctuation rules: semi, quotes, comma-dangle, comma-spacing
  • Modern JS rules: arrow-parens, arrow-spacing, template-curly-spacing
  • And 49 additional rules covering all aspects of JavaScript formatting

TypeScript Support

Complete TypeScript definitions are provided:

import type { Rules, UnprefixedRuleOptions } from '@stylistic/eslint-plugin-js';

// Type for all rule modules
type Rules = {
  [K in keyof UnprefixedRuleOptions]: Rule.RuleModule
};

// Type for rule options
type RuleOptions = {
  '@stylistic/js/indent': ['off' | 'warn' | 'error', number | 'tab', IndentOptions?];
  '@stylistic/js/semi': ['off' | 'warn' | 'error', 'always' | 'never', SemiOptions?];
  // ... all other rules
};

Configuration Helper Types

// For eslint-define-config users
declare module 'eslint-define-config' {
  export interface CustomRuleOptions extends RuleOptions {}
}

Install with Tessl CLI

npx tessl i tessl/npm-stylistic--eslint-plugin-js

docs

array-formatting.md

code-quality-consistency.md

function-formatting.md

index.md

line-breaks-newlines.md

modern-javascript.md

object-formatting.md

plugin-configuration.md

punctuation-operators.md

spacing-indentation.md

tile.json