Read our style guide
$ pnpm add --save-dev --save-exact @shelf/eslint-configimport tsConfig from '@shelf/eslint-config/typescript.js';
export default [...tsConfig];import feTsConfig from '@shelf/eslint-config/frontend-typescript.js';
export default [
...feTsConfig,
{
settings: {
react: {
version: 'detect',
},
},
},
];Repos that move formatting out of ESLint and into Oxfmt should use the additive no-Prettier entrypoints:
import tsConfig from '@shelf/eslint-config/typescript-no-prettier.js';
export default [...tsConfig];import feTsConfig from '@shelf/eslint-config/frontend-typescript-no-prettier.js';
export default [
...feTsConfig,
{
settings: {
react: {
version: 'detect',
},
},
},
];The legacy typescript.js and frontend-typescript.js entrypoints stay supported for repos that still format through Prettier.
Frontend configs enforce shelf/prefer-swr-mutation. The rule reports React loading state that is manually toggled around an awaited fetch, Axios call, or Shelf API/client call:
// Incorrect
const [isSaving, setIsSaving] = useState(false);
const save = async () => {
setIsSaving(true);
try {
await ContentApi.save();
} finally {
setIsSaving(false);
}
};Use the mutation lifecycle as the source of truth instead:
const {trigger: save, isMutating: isSaving} = useSWRMutation('save-content', () =>
ContentApi.save()
);Local UI state and asynchronous work that does not call a remote API remain valid.
$ pnpx npMIT © Shelf