no-sync
UnreleasedConfiguration
Disallow synchronous calls identified by names ending in Sync.
Synchronous I/O can block other work in a Node.js application. Prefer an asynchronous API where the surrounding code can wait for its result.
Examples
The rule checks names without requiring a Node.js import. It also checks direct
identifier arguments, such as consume(readFileSync), and identifiers inside a
member-expression callee. String keys such as fs['readFileSync']() are allowed.
The rule provides no automatic fixes or suggestions.
Options
allowAtRootLevel
Set allowAtRootLevel to true to allow synchronous calls outside functions.
The default is false. Top-level blocks and class field initializers are also
outside functions; method bodies and function parameter defaults are inside.
ignores
The default is []. Strings ignore exact identifier names:
Object entries use TypeScript declaration information:
Use / separators in file patterns on every platform. Backslashes escape glob
characters. Package patterns are JavaScript regular expressions in Unicode mode;
invalid patterns, such as (, are configuration errors.
Each object can include a name array. These names refer to the declared type,
including its containing class or interface, such as
{ from: 'lib', name: ['CSSStyleSheet.replaceSync'] }. Imported aliases use the
original declaration name. Omit name to ignore all matching declarations.
Differences from upstream
- When type information is unavailable, object entries in
ignoressuppress nothing; string entries still apply. Upstream stops with an error in this case. - An empty file pattern ignores no declarations. Upstream stops with an error.
- File patterns such as
./helpers.tsalso work on Windows and in working directories containing uppercase letters on case-insensitive file systems. Upstream can fail to ignore matching declarations in these cases. - Directory checks distinguish siblings with a shared prefix. For example, with
typeRoots: ['./types'],{ from: 'file' }can ignore declarations intypes-extra/helper.ts; upstream incorrectly excludes them. A file glob cannot match declarations in a siblingproject-extradirectory when the working directory isproject, even though upstream may accept them. - Package patterns are validated before linting. Upstream may only report an
invalid pattern when it encounters a matching call. Long Unicode property
names such as
\p{Letter}are unsupported; use\p{L}instead.
Some file globs match differently. The table shows whether each pattern ignores
an example declaration in a case-sensitive project directory. Prefer explicit
paths, **/foo.ts, or alternatives such as **/*.{ts,tsx} when sharing a
configuration with upstream.