@@ -61,6 +61,7 @@ fs.readFileSync(somePath).toString();
6161#### ignores
6262
6363You can ` ignore ` specific function names using this option.
64+ Additionally, if you are using TypeScript you can optionally specify where the function is declared.
6465
6566Examples of ** incorrect** code for this rule with the ` { ignores: ['readFileSync'] } ` option:
6667
@@ -78,6 +79,62 @@ Examples of **correct** code for this rule with the `{ ignores: ['readFileSync']
7879fs .readFileSync (somePath);
7980```
8081
82+ ##### Advanced (TypeScript only)
83+
84+ You can provide a list of specifiers to ignore. Specifiers are typed as follows:
85+
86+ ``` ts
87+ type Specifier =
88+ | string
89+ | {
90+ from: " file" ;
91+ path? : string ;
92+ name? : string [];
93+ }
94+ | {
95+ from: " package" ;
96+ package? : string ;
97+ name? : string [];
98+ }
99+ | {
100+ from: " lib" ;
101+ name? : string [];
102+ }
103+ ` ` `
104+
105+ ###### From a file
106+
107+ Examples of **correct** code for this rule with the ignore file specifier:
108+
109+ ` ` ` js
110+ /* eslint n/no-sync: ["error", { ignores: [{ from: 'file', path: './foo.ts' }]}] */
111+
112+ import { fooSync } from " ./foo"
113+ fooSync ()
114+ ```
115+
116+ ###### From a package
117+
118+ Examples of ** correct** code for this rule with the ignore package specifier:
119+
120+ ``` js
121+ /* eslint n/no-sync: ["error", { ignores: [{ from: 'package', package: 'effect' }]}] */
122+
123+ import { Effect } from " effect"
124+ const value = Effect .runSync (Effect .succeed (42 ))
125+ ```
126+
127+ ###### From the TypeScript library
128+
129+ Examples of ** correct** code for this rule with the ignore lib specifier:
130+
131+ ``` js
132+ /* eslint n/no-sync: ["error", { ignores: [{ from: 'lib' }]}] */
133+
134+ const stylesheet = new CSSStyleSheet ()
135+ stylesheet .replaceSync (" body { font-size: 1.4em; } p { color: red; }" )
136+ ```
137+
81138## 🔎 Implementation
82139
83140- [ Rule source] ( ../../lib/rules/no-sync.js )
0 commit comments