xo

  • Version 1.1.0
  • Published
  • 77 kB
  • 31 dependencies
  • MIT license

Install

npm i xo
yarn add xo
pnpm add xo

Overview

JavaScript/TypeScript linter (ESLint wrapper) with great defaults

Index

Classes

class Xo

class Xo {}

    constructor

    constructor(_linterOptions: LinterOptions, _baseXoConfig?: XoConfigOptions);

      property baseXoConfig

      baseXoConfig: XoConfigOptions;
      • Base XO config options that allow configuration from CLI or other sources. Not to be confused with the xoConfig property which is the resolved XO config from the flat config AND base config.

      property cacheLocation

      cacheLocation: string;
      • File path to the ESLint cache.

      property eslint

      eslint?: ESLint;
      • A re-usable ESLint instance configured with options calculated from the XO config.

      property eslintConfig

      eslintConfig?: Linter.Config[];
      • The ESLint config calculated from the resolved XO config.

      property flatConfigPath

      flatConfigPath?: string;
      • The flat XO config path, if there is one.

      property linterOptions

      linterOptions: LinterOptions;
      • Required linter options: cwd, fix, and filePath (in case of lintText).

      property prettier

      prettier?: boolean;
      • If any user configs container Prettier, we will need to fetch the Prettier config.

      property prettierConfig

      prettierConfig?: prettier.Options;
      • The Prettier config if it exists and is needed.

      property xoConfig

      xoConfig?: Simplify<
      XoConfigOptions &
      Omit<Linter.Config, 'files' | 'ignores'> & {
      files?: string | string[];
      ignores?: string | string[];
      }
      >[];
      • XO config derived from both the base config and the resolved flat config.

      property xoToEslintConfig

      static xoToEslintConfig: (
      flatXoConfig: Simplify<
      XoConfigOptions &
      Omit<Linter.Config, 'files' | 'ignores'> & {
      files?: string | string[];
      ignores?: string | string[];
      }
      >[],
      { prettierOptions }?: CreateConfigOptions
      ) => Linter.Config[];
      • Static helper to convert an XO config to an ESLint config to be used in eslint.config.js.

      method calculateConfigForFile

      calculateConfigForFile: (filePath: string) => Promise<Linter.Config>;

        method getFormatter

        getFormatter: (name: string) => Promise<ESLint.LoadedFormatter>;

          method handleUnincludedTsFiles

          handleUnincludedTsFiles: (files?: string[]) => Promise<void>;
          • Checks every TS file to ensure its included in the tsconfig and any that are not included are added to a generated tsconfig for type aware linting.

            Parameter files

            The TypeScript files being linted.

          method initEslint

          initEslint: (files?: string[]) => Promise<void>;
          • Initializes the ESLint instance on the XO instance.

          method lintFiles

          static lintFiles: (
          globs: string | undefined,
          options: LinterOptions & XoConfigOptions
          ) => Promise<XoLintResult>;
          • Static helper for backwards compatibility and use in editor extensions and other tools.

          • Lints the files on the XO instance.

            Parameter globs

            Glob pattern to pass to globby.

            Throws

            Error

          method lintText

          static lintText: (
          code: string,
          options: LintTextOptions & LinterOptions & XoConfigOptions
          ) => Promise<XoLintResult>;
          • Static helper for backwards compatibility and use in editor extensions and other tools.

          • Lints the text on the XO instance.

          method outputFixes

          static outputFixes: (results: XoLintResult) => Promise<void>;
          • Write the fixes to disk.

          method setEslintConfig

          setEslintConfig: () => void;
          • Sets the ESLint config on the XO instance.

          method setIgnores

          setIgnores: () => void;
          • Sets the ignores on the XO instance.

          method setXoConfig

          setXoConfig: () => Promise<void>;
          • Sets the XO config on the XO instance.

          Package Files (1)

          Dependencies (31)

          Dev Dependencies (16)

          Peer Dependencies (0)

          No peer dependencies.

          Badge

          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/xo.

          • Markdown
            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/xo)
          • HTML
            <a href="https://www.jsdocs.io/package/xo"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>