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
, andfilePath
(in case oflintText
).
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)
- @eslint-community/eslint-plugin-eslint-comments
- @sindresorhus/tsconfig
- @stylistic/eslint-plugin
- @typescript-eslint/parser
- arrify
- cosmiconfig
- define-lazy-prop
- eslint
- eslint-config-prettier
- eslint-config-xo-react
- eslint-config-xo-typescript
- eslint-formatter-pretty
- eslint-plugin-ava
- eslint-plugin-import-x
- eslint-plugin-n
- eslint-plugin-no-use-extend-native
- eslint-plugin-prettier
- eslint-plugin-promise
- eslint-plugin-unicorn
- find-cache-directory
- get-stdin
- get-tsconfig
- globals
- globby
- meow
- micromatch
- open-editor
- path-exists
- prettier
- type-fest
- typescript-eslint
Dev Dependencies (16)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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[](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>
- Updated .
Package analyzed in 3571 ms. - Missing or incorrect documentation? Open an issue for this package.