Repository navigation
v3.8.0
v3.8.0: Six new rules for project conventions and React code
Adds six rules: curly, no-jsx-spread-child, no-real-temporary-directory, no-runtime-in-type-files, no-test-timeout, and require-tsx-for-hooks. No existing rule's tests changed, and require-readable-spacing also accepts break and continue as statement kinds.
🚀 Added
- curly: The rule requires braces on
ifandelsebranches and loop bodies, and reports braces around a lonereturn,break, orcontinuein anifwithoutelsethat fits on one line. For example,if (x) list.push(y);reports, and the fix adds braces. - by @howmanysmall in #102 - no-jsx-spread-child: The rule reports a spread between JSX tags, such as
<List>{...items}</List>, which stops the React Compiler from memoizing the component. Use{items}instead, which renders the same tree. - by @howmanysmall in #102 - no-real-temporary-directory: The rule reports calls to
tmpdirfromos, and tomkdtempormkdtempSyncfromfs,fs/promises, orfs.promises, with or withoutnode:. A memfs call such asvol.mkdtempSync('x')passes. - by @howmanysmall in #102 - no-runtime-in-type-files: The rule reports each top-level value, function, class, enum, namespace, bare import, and value import or export in files matching
files, which defaults to**/packages/*/src/lib/**/*-types.ts.export const value = 1;reports, whileexport type { Input } from "./input";passes. - by @howmanysmall in #102 - no-test-timeout: The rule reports a timeout argument after a
test,it, ordescribecallback, and atimeoutkey in an options object, including.only,.each, and.skipIfchains. For example,test('name', () => {}, 5000);reports. - by @howmanysmall in #102 - require-readable-spacing: The
overridesentries'previousandnextfields now acceptbreakandcontinue, as in"previous": "break". Previously the schema rejected both values. - by @howmanysmall in #102 - require-tsx-for-hooks: The rule reports a hook declared in a
.tsfile, where a hook is a function namedusefollowed by a capital letter or digit. For example,export function useThing() { return 1; }inuse-thing.tsreports, and the same code in a.tsxfile passes. - by @howmanysmall in #102
Turn off core curly before you enable small-rules/curly. curly takes allowLiteralReturns (default false), oneLineBodies (default ["break", "continue", "return"]), printWidth (default 120), and tabWidth (default 4). The examples below also show the additionalFunctions option for no-real-temporary-directory and the additionalTestFunctions option for no-test-timeout.
"curly": "off",
"small-rules/curly": "error",
"small-rules/no-real-temporary-directory": ["error", { "additionalFunctions": [{ "source": "tmp", "functions": ["dirSync", "promises.dir"] }] }],
"small-rules/no-test-timeout": ["error", { "additionalTestFunctions": ["scenario"] }]Full Changelog: v3.7.0...v3.8.0