I need some linting rules to throw either an error or a warning depending on whether the build is development or production. In a React component file during development process.env.NODE_ENV === 'development'.
In eslintrc.js I have:
const production = process.env.NODE_ENV !== 'development'; // returns true
console.log('%c process.env.NODE_ENV', 'color: green;', process.env.NODE_ENV); // returns undefined
I want to be able to switch between linting rule warnings. and errors like this:
rules: {
'no-tabs': 0,
indent: [2, 'tab', { SwitchCase: 1, VariableDeclarator: 1 }],
'react/jsx-props-no-spreading': 'off',
'no-unused-vars':
production
? 'error'
: 'warn',
Why is process.env.NODE_ENV undefined and how can I fix this?