Skip to content

@onerepo/plugin-eslint

Install via npm
npm install --save-dev @onerepo/plugin-eslint
eslint(opts): Plugin

Include the eslint plugin in your oneRepo plugin setup:

onerepo.config.ts
import { eslint } from '@onerepo/plugin-eslint';
export default {
plugins: [eslint()],
};
ParameterType
optsOptions
type Options: {
extensions: string[];
githubAnnotate: boolean;
name: string | string[];
quiet: boolean;
};

Options for configuring the ESLint plugin for oneRepo.

onerepo.config.js
export default {
plugins: [
eslint({
extensions: ['ts', 'tsx', 'astro', 'js', 'cjs', 'mjs'],
}),
],
};
optional extensions: string[];

List of file extensions (without the .) that ESLint should operate across. Omit this if using the new flat configuration.

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.

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.

optional quiet: boolean;

Control the ESLint setting default to suppress warnings and only report errors.

./onerepo.config.ts
import 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:

./onerepo.config.ts
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;

Aliases: one lint

Run eslint across files and Workspaces.

Terminal window
one eslint [options...]
OptionTypeDescription
--addbooleanAdd modified files after write to the git stage.
--affectedbooleanSelect all affected Workspaces. If no other inputs are chosen, this will default to true.
--all, -abooleanRun across all Workspaces
--cacheboolean, default: trueUse cache if available
--extensionsarrayMake ESLint check files given these extensions.
--files, -farrayDetermine Workspaces from specific files
--fixboolean, default: trueApply auto-fixes if possible
--prettyboolean, default: trueControl ESLint’s --color flag.
--quietbooleanReport errors only
--stagedbooleanUse 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.
--workspaces, -warrayList of Workspace names to run against
Advanced options
OptionTypeDescription
--from-refstringGit ref to start looking for affected files or Workspaces
--github-annotateboolean, default: trueAnnotate files in GitHub with errors when failing lint checks in GitHub Actions
--show-advancedbooleanPair with --help to show advanced options.
--through-refstringGit ref to start looking for affected files or Workspaces