@onerepo/plugin-eslint
Installation
Section titled Installationnpm install --save-dev @onerepo/plugin-eslint
yarn add --dev @onerepo/plugin-eslint
pnpm install --save-dev @onerepo/plugin-eslint
Configuration
Section titled Configurationeslint()
Section titled eslint()function eslint(opts): Plugin;
Include the eslint
plugin in your oneRepo plugin setup:
import { eslint } from '@onerepo/plugin-eslint';
export default { plugins: [eslint()],};
Parameters
Section titled ParametersParameter | Type |
---|---|
opts | Options |
Options
Section titled Optionstype Options: { extensions: string[]; githubAnnotate: boolean; name: string | string[]; warnings: boolean;};
Options for configuring the ESLint plugin for oneRepo.
export default { plugins: [ eslint({ extensions: ['ts', 'tsx', 'astro', 'js', 'cjs', 'mjs'], }), ],};
Type declaration
Section titled Type declarationextensions?
Section titled extensions?optional extensions: string[];
List of file extensions (without the .
) that ESLint should operate across. Omit this if using the new flat configuration.
githubAnnotate?
Section titled githubAnnotate?optional githubAnnotate: boolean;
When true
or unset and run in GitHub Actions, any files failing format checks will be annotated with an error in the GitHub user interface.
name?
Section titled name?optional name: string | string[];
The name of the eslint command. You might change this to 'lint'
or ['lint', 'eslint']
to keep things more familiar for most developers.
warnings?
Section titled warnings?optional warnings: boolean;
Control the ESLint setting default to suppress warnings and only report errors.
Recommended tasks
Section titled Recommended tasksimport type { Config } from 'onerepo';
export default { tasks: { 'pre-commit': { serial: ['$0 eslint --add'], }, 'pre-merge': { serial: ['$0 eslint --all --no-fix'], }, },} satisfies Config;
If you’re also running Prettier, it is important to run ESLint _before__ Prettier. Do this by creating sequential tasks: an array of tasks within the serial
tasks array:
import type { Config } from 'onerepo';
export default { tasks: { 'pre-commit': { serial: [['$0 eslint --add', '$0 prettier --add']], }, 'pre-merge': { serial: [['$0 eslint --all --no-fix', '$0 prettier --check']], }, },} satisfies Config;
Commands
Section titled Commandsone eslint
Section titled one eslintAliases: one lint
Run eslint across files and Workspaces.
one eslint [options...]
Option | Type | Description |
---|---|---|
--add | boolean | Add modified files after write to the git stage. |
--affected | boolean | Select all affected Workspaces. If no other inputs are chosen, this will default to true . |
--all, -a | boolean | Run across all Workspaces |
--cache | boolean , default: true | Use cache if available |
--extensions | array | Make ESLint check files given these extensions. |
--files, -f | array | Determine Workspaces from specific files |
--fix | boolean , default: true | Apply auto-fixes if possible |
--pretty | boolean , default: true | Control ESLint’s --color flag. |
--staged | boolean | Use files on the git stage to calculate affected files or Workspaces. When unset or --no-staged , changes will be calculated from the entire branch, since its fork point. |
--warnings, --warn | boolean , default: true | Report warnings from ESLint. |
--workspaces, -w | array | List of Workspace names to run against |
Advanced options
Option | Type | Description |
---|---|---|
--from-ref | string | Git ref to start looking for affected files or Workspaces |
--github-annotate | boolean , default: true | Annotate files in GitHub with errors when failing lint checks in GitHub Actions |
--show-advanced | boolean | Pair with --help to show advanced options. |
--through-ref | string | Git ref to start looking for affected files or Workspaces |