Skip to content

Commit

Permalink
feat(experimental-utils): console.warn on import of experimental-utils (
Browse files Browse the repository at this point in the history
#6179)

feat(experimental-utils) console.warn on import of experimental-utils
  • Loading branch information
kball committed Dec 8, 2022
1 parent e9aafbf commit 0b7476b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/experimental-utils/package.json
Expand Up @@ -35,6 +35,7 @@
"postclean": "rimraf dist && rimraf _ts3.4 && rimraf coverage",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "nx lint",
"test": "jest",
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
Expand Down
8 changes: 7 additions & 1 deletion packages/experimental-utils/src/index.ts
@@ -1,2 +1,8 @@
// TODO (#4139): Once typescript-eslint hits v7, this package will console.warn to switch...
/* eslint-disable no-console */
console.warn(
'This package is purely a re-export of `@typescript-eslint/utils`.',
);
console.warn(
'You should switch to importing from that non-experimental package instead.',
);
export * from '@typescript-eslint/utils';
10 changes: 10 additions & 0 deletions packages/experimental-utils/tests/consoleWarning.test.ts
@@ -0,0 +1,10 @@
describe('importing', () => {
it('should console a warning', () => {
const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
require('../src/index');
expect(warn).toHaveBeenCalledTimes(2);
expect(warn).toHaveBeenLastCalledWith(
'You should switch to importing from that non-experimental package instead.',
);
});
});

0 comments on commit 0b7476b

Please sign in to comment.