Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
run only for lib files
  • Loading branch information
rluvaton committed Jul 3, 2023
commit 94ab2e1baf75f1983a8442182a15455f96240147
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ module.exports = {
},
] },
},
{
files: ['lib/**/*.js', 'lib/**/*.cjs', 'lib/**/*.mjs'],
rules: {
'node-core/set-proto-to-null-in-object': 'error',
},

}
],
rules: {
// ESLint built-in rules
Expand Down Expand Up @@ -316,7 +323,6 @@ module.exports = {
'node-core/no-unescaped-regexp-dot': 'error',
'node-core/no-duplicate-requires': 'error',
'node-core/prefer-proto': 'error',
'node-core/set-proto-to-null-in-object': 'error',
},
globals: {
ByteLengthQueuingStrategy: 'readable',
Expand Down
6 changes: 3 additions & 3 deletions tools/eslint-rules/set-proto-to-null-in-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ module.exports = {
context.report({
node,
message: 'Every object must have __proto__: null',
fix: function (fixer) {
fix: function(fixer) {
// Generate the fix suggestion to add __proto__: null
const sourceCode = context.getSourceCode();
const firstProperty = properties[0];
const firstPropertyToken = sourceCode.getFirstToken(firstProperty);
const fixText = `__proto__: null, `;
const fixText = '__proto__: null, ';

// Insert the fix suggestion before the first property
return fixer.insertTextBefore(firstPropertyToken, fixText);
Expand All @@ -41,7 +41,7 @@ module.exports = {
context.report({
node,
message: 'Every empty object must have __proto__: null',
fix: function (fixer) {
fix: function(fixer) {
// Generate the fix suggestion to create the object with __proto__: null
const fixText = '{ __proto__: null }';

Expand Down