Skip to content

Commit

Permalink
add .gitattributes and format
Browse files Browse the repository at this point in the history
  • Loading branch information
CloudNStoyan committed Sep 23, 2024
1 parent 2ab12b8 commit 0e773ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
"use strict";
'use strict';

/** @type {import('eslint').Rule.RuleModule} */
module.exports = {
meta: {
messages: {
requireDependencyArray: "useEffect should have a dependency array.",
requireDependencyArray: 'useEffect should have a dependency array.',
},
type: "problem",
type: 'problem',
docs: {
description: "Enforce that useEffect has a dependency array.",
description: 'Enforce that useEffect has a dependency array.',
recommended: true,
},
fixable: "code",
fixable: 'code',
schema: [],
},
create(context) {
return {
CallExpression(node) {
if (
node.callee.type === "Identifier" &&
node.callee.name === "useEffect"
node.callee.type === 'Identifier' &&
node.callee.name === 'useEffect'
) {
const dependencies = node.arguments[1];
if (!(dependencies && dependencies.type === "ArrayExpression")) {
if (!(dependencies && dependencies.type === 'ArrayExpression')) {
context.report({
node,
messageId: "requireDependencyArray",
messageId: 'requireDependencyArray',
fix(fixer) {
return fixer.insertTextAfter(node.arguments[0], ", []");
return fixer.insertTextAfter(node.arguments[0], ', []');
},
});
}
Expand Down

0 comments on commit 0e773ab

Please sign in to comment.