Skip to content

Commit

Permalink
Forbid console log() statements in ESLint
Browse files Browse the repository at this point in the history
Signed-off-by: Joeyyy09 <[email protected]>
  • Loading branch information
joeyyy09 committed Apr 11, 2024
1 parent 9014fb5 commit 7491ba2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends" : [
"extends": [
"@visionappscz/eslint-config-visionapps"
],
"env": {
Expand All @@ -17,6 +17,7 @@
],
"parser": "@babel/eslint-parser",
"rules": {
"import/prefer-default-export": "off"
"import/prefer-default-export": "off",
"no-console": "error"
}
}
3 changes: 3 additions & 0 deletions src/components/_helpers/__tests__/transferProps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ describe('transferProps', () => {
const expectedProps = { propA: 'value' };

let errorString;
// eslint-disable-next-line no-console
const originalConsoleError = console.error;
// eslint-disable-next-line no-console
console.error = (error) => {
errorString = error;
};
expect(transferProps(props)).toEqual(expectedProps);
expect(errorString).toEqual('Invalid prop(s) supplied to the "transferProps" function: "className", "contentEditable"');

// eslint-disable-next-line no-console
console.error = originalConsoleError;
});
});
1 change: 0 additions & 1 deletion src/components/_helpers/transferProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const transferProps = (props) => {
} = props;

if (process.env.NODE_ENV !== 'production') {
console.log('props', props);
const invalidProps = [
'children', // It is always either handled by the component itself or not supported.
'className', // Classes are set by component authors, changing it arbitrarily might break things.
Expand Down

0 comments on commit 7491ba2

Please sign in to comment.