n/no-path-concat
eslint-plugin-n
No autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/no-path-concat": "error",
},
},
];Disallow string concatenation with __dirname, __filename, and import.meta paths
const fullPath1 = __dirname + "/foo.js";
const fullPath2 = __filename + "/foo.js";
const fullPath3 = `${__dirname}/foo.js`;
const fullPath4 = `${__filename}/foo.js`;
const fullPath5 = import.meta.dirname + "/foo.js";
const fullPath6 = import.meta.filename + "/foo.js";
const fullUrl = import.meta.url + "/foo.js";const fullPath1 = path.join(__dirname, "foo.js");
const fullPath2 = path.join(__filename, "foo.js");
const fullPath3 = __dirname + ".js";
const fullPath4 = __filename + ".map";
const fullPath5 = `${__dirname}_foo.js`;
const fullPath6 = `${__filename}.test.js`;
const fullPath7 = path.join(import.meta.dirname, "foo.js");
const fullPath8 = path.join(import.meta.filename, "foo.js");
const fullUrl = new URL("./foo.js", import.meta.url);Examples from the ESLint documentation.
n/no-path-concat
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/no-path-concat": "error",
},
},
];node/no-path-concat
node plugin · restriction
{
"plugins": [
"node"
],
"rules": {
"node/no-path-concat": "error"
}
}nursery/noPathConcat
nursery · since 2.6.3
{
"linter": {
"rules": {
"nursery": {
"noPathConcat": "error"
}
}
}
}Disallow string concatenation with __dirname and __filename
Require that process.exit() expressions use the same code path as throw
Disallow import declarations which import extraneous modules