Skip to content

v3.8.0

Choose a tag to compare

@github-actions github-actions released this 24 Oct 23:51
· 10 commits to main since this release
v3.8.0
f6a3273

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 if and else branches and loop bodies, and reports braces around a lone return, break, or continue in an if without else that 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 tmpdir from os, and to mkdtemp or mkdtempSync from fs, fs/promises, or fs.promises, with or without node:. A memfs call such as vol.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, while export type { Input } from "./input"; passes. - by @howmanysmall in #102
  • no-test-timeout: The rule reports a timeout argument after a test, it, or describe callback, and a timeout key in an options object, including .only, .each, and .skipIf chains. For example, test('name', () => {}, 5000); reports. - by @howmanysmall in #102
  • require-readable-spacing: The overrides entries' previous and next fields now accept break and continue, 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 .ts file, where a hook is a function named use followed by a capital letter or digit. For example, export function useThing() { return 1; } in use-thing.ts reports, and the same code in a .tsx file 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