Basic code refactors with the help of ChatGPT
To use:
- Create a
OPENAI_KEY
in your.env
file - Create a config file, called
refactorer.js
in your project root.
The content of the file should look something like this:
module.exports = {
globPatterns: ['./components/**/*.tsx', './pages/**/*.tsx', './lib/**/*.ts'],
refactorReasons: [
"'import useTranslation from 'next-translate/useTranslation'",
],
instructions: [
"Remove `import useTranslation from 'next-translate/useTranslation';` if it exists",
'Remove `const { t } = useTranslation();` if it exists',
'Add `t: (key: string) => string` to the props of the component',
'Add `t` to the destructured props of the component',
],
};
then just run:
npx refactorer [command]
refactor
Starts the refactoring