Always use explicit path resolution and document ordering requirements in configuration files to prevent environment-dependent issues. This makes configurations more reliable and self-documenting.
Always use explicit path resolution and document ordering requirements in configuration files to prevent environment-dependent issues. This makes configurations more reliable and self-documenting.
For file paths in configuration files:
require.resolve()
instead of relative paths to ensure consistent resolution across environmentsExample:
// Bad
module.exports = {
extends: [
'eslint-config-airbnb',
'./eslint/config-airbnb-typescript.js',
]
};
// Good
module.exports = {
extends: [
'eslint-config-airbnb',
require.resolve('./eslint/config-airbnb-typescript.js'),
]
};
// Even better - with documentation
const plugins = [];
// must be loaded last: https://github.com/tailwindlabs/prettier-plugin-tailwindcss?tab=readme-ov-file#compatibility-with-other-prettier-plugins
plugins.push('prettier-plugin-tailwindcss');
// For complex environment variables, include thorough documentation
/**
* Fun facts about the `process.env.CONTEXT`:
* - It is defined by Netlify environment variables
* - `process.env.CONTEXT === 'production'` means...
*/
This approach prevents subtle configuration bugs that only appear in certain environments, reduces onboarding friction for new developers, and creates self-documenting configuration files.
Enter the URL of a public GitHub repository