n/no-sync
eslint-plugin-n
No autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/no-sync": "error",
},
},
];fs.existsSync(somePath);
function foo() {
var contents = fs.readFileSync(somePath).toString();
}function foo() {
var contents = fs.readFileSync(somePath).toString();
}
var bar = baz => fs.readFileSync(qux);fs.readdirSync(somePath);obj.sync();
async(function() {
// ...
});fs.readFileSync(somePath).toString();fs.readFileSync(somePath);Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
n/no-sync
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/no-sync": "error",
},
},
];node/no-sync
node plugin · style
{
"plugins": [
"node"
],
"rules": {
"node/no-sync": "error"
}
}nursery/noSyncMethods
nursery · since 2.6.5
{
"linter": {
"rules": {
"nursery": {
"noSyncMethods": "error"
}
}
}
}Enforce using process.getBuiltinModule() to load Node.js built-in modules
Enforce the style of file extensions in import declarations