eslint-plugin-turbo
The eslint-plugin-turbo package helps you find environment variables that are used in your code that are not a part of Turborepo's hashing. Environment variables used in your source code that are not accounted for in turbo.json will be highlighted in your editor and errors will show as ESLint output.
Install eslint-plugin-turbo into the location where your ESLint configuration is held:
pnpm yarn npm bun nub aube
pnpm add eslint-plugin-turbo --filter=@repo/eslint-config yarn workspace @acme/eslint-config add eslint-plugin-turbo --dev npm i --save-dev eslint-plugin-turbo -w @acme/eslint-config cd packages/eslint-config && bun install eslint-plugin-turbo --dev cd packages/eslint-config && nub add eslint-plugin-turbo --save-dev cd packages/eslint-config && aube add eslint-plugin-turbo --save-dev
ESLint v9 uses the Flat Config format seen below:
./packages/eslint-config/base.js import turbo from " eslint-plugin-turbo " ;
export default [turbo . configs[ " flat/recommended " ]] ;
Otherwise, you may configure the rules you want to use under the rules section.
./packages/eslint-config/base.js import turbo from " eslint-plugin-turbo " ;
export default [
{
plugins : {
turbo ,
},
rules : {
" turbo/no-undeclared-env-vars " : " error " ,
},
},
] ;
./packages/eslint-config/base.js import turbo from " eslint-plugin-turbo " ;
export default [
{
plugins : {
turbo ,
},
rules : {
" turbo/no-undeclared-env-vars " : [
" error " ,
{
allowList : [ " ^ENV_[A-Z]+$ " ] ,
},
] ,
},
},
] ;
Add turbo to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
./packages/eslint-config/base.json
Then configure the rules you want to use under the rules section.
./packages/eslint-config/base.json {
" rules " : {
" turbo/no-undeclared-env-vars " : " error "
}
}
./packages/eslint-config/base.json {
" plugins " : [ " turbo " ],
" rules " : {
" turbo/no-undeclared-env-vars " : [
" error " ,
{
" allowList " : [ " ^ENV_[A-Z]+$ " ]
}
]
}
}