Skip to content

Commit b75e41d

Browse files
authored
Merge pull request #45 from byondrnd/cancel-LINT_COMMENT_PREFIX
Cancel lint comment prefix
2 parents 9fc0fed + a32f25a commit b75e41d

File tree

3 files changed

+79
-83
lines changed

3 files changed

+79
-83
lines changed

.changeset/cyan-spiders-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@byondxr/eslint-plugin-automate": patch
3+
---
4+
5+
LINT_COMMENT_PREFIX

.eslintrc.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
"node": true,
66
"browser": true
77
},
8-
"plugins": [
9-
"unused-imports",
10-
"@typescript-eslint",
11-
"prefer-arrow-functions",
12-
"import",
13-
"react-refresh",
14-
"jsx-a11y"
15-
],
8+
"plugins": ["unused-imports", "@typescript-eslint", "import", "react-refresh", "jsx-a11y"],
169
"parser": "@typescript-eslint/parser",
1710
"parserOptions": {
1811
"ecmaFeatures": {
@@ -58,6 +51,7 @@
5851
},
5952
{
6053
"files": ["*.ts", "*.tsx"],
54+
"plugins": ["prefer-arrow-functions"],
6155
"rules": {
6256
"import/order": [
6357
"error",

packages/eslint-plugin-automate/src/rules/exhaustive-deps.ts

Lines changed: 72 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44

55
import { ESLintUtils } from '@typescript-eslint/utils'
66
import {
7-
getCurrentLineRange,
8-
getPrevLineRange,
9-
getUpdatedLintComment,
7+
// getCurrentLineRange,
8+
// getPrevLineRange,
9+
// getUpdatedLintComment,
1010
isNodeTypeIncludesFunction,
11-
LINT_COMMENT_PREFIX,
12-
SELECTOR_LOCAL_FUNCTION_DEPENDECY_COMMENT,
13-
SELECTOR_LOCAL_REF_DEPENDECY_COMMENT,
1411
} from '../utils/ast-utils'
1512
// CHANGE V1
1613

@@ -443,34 +440,34 @@ const rule = createESLintRule<Options, MessageIds>({
443440
const dependencyNode = getDependency(referenceNode, isHookIncludeAllDeps)
444441
const dependency = analyzePropertyChain(dependencyNode, optionalChains)
445442

446-
// CHANGE V3 TODO
447-
let _node = dependencyNode
448-
let currentLine = _node.loc.start.line
449-
let prevLineText = context.getSourceCode().getLines()[currentLine - 2]
450-
if (
451-
dependencyNode.type === 'MemberExpression' &&
452-
dependencyNode.property.type === 'Identifier' &&
453-
dependencyNode.property.name === 'current'
454-
) {
455-
const existingComment = prevLineText?.includes(LINT_COMMENT_PREFIX) ? prevLineText : ''
456-
const newFlag = `${_node.object.name}.${_node.property.name} - ${SELECTOR_LOCAL_REF_DEPENDECY_COMMENT}`
457-
const newComment = getUpdatedLintComment(newFlag, existingComment)
458-
if (!prevLineText?.includes(newFlag)) {
459-
context.report({
460-
node: _node,
461-
messageId:
462-
'will be noted as local dependency causing a selector to not be cached globally',
463-
fix(fixer) {
464-
return prevLineText.includes(LINT_COMMENT_PREFIX)
465-
? fixer.replaceTextRange(getPrevLineRange(context, _node), `${newComment}`)
466-
: fixer.insertTextBeforeRange(
467-
getCurrentLineRange(context, _node),
468-
`${newComment}\n`
469-
)
470-
},
471-
})
472-
}
473-
}
443+
// // CHANGE V3 TODO
444+
// let _node = dependencyNode
445+
// let currentLine = _node.loc.start.line
446+
// let prevLineText = context.getSourceCode().getLines()[currentLine - 2]
447+
// if (
448+
// dependencyNode.type === 'MemberExpression' &&
449+
// dependencyNode.property.type === 'Identifier' &&
450+
// dependencyNode.property.name === 'current'
451+
// ) {
452+
// const existingComment = prevLineText?.includes(LINT_COMMENT_PREFIX) ? prevLineText : ''
453+
// const newFlag = `${_node.object.name}.${_node.property.name} - ${SELECTOR_LOCAL_REF_DEPENDECY_COMMENT}`
454+
// const newComment = getUpdatedLintComment(newFlag, existingComment)
455+
// if (!prevLineText?.includes(newFlag)) {
456+
// context.report({
457+
// node: _node,
458+
// messageId:
459+
// 'will be noted as local dependency causing a selector to not be cached globally',
460+
// fix(fixer) {
461+
// return prevLineText.includes(LINT_COMMENT_PREFIX)
462+
// ? fixer.replaceTextRange(getPrevLineRange(context, _node), `${newComment}`)
463+
// : fixer.insertTextBeforeRange(
464+
// getCurrentLineRange(context, _node),
465+
// `${newComment}\n`
466+
// )
467+
// },
468+
// })
469+
// }
470+
// }
474471
// else if (prevLineText?.includes('ref dependency')) {
475472
// context.report({
476473
// node: _node,
@@ -1355,49 +1352,49 @@ function collectRecommendations({
13551352
isNodeTypeIncludesFunction(context, value.references[0].identifier)
13561353
)
13571354
),
1358-
]
1355+
]
13591356
: [_dependencies, new Map()]
13601357

1361-
if (isHookIncludeAllDeps && functionDeps.size > 0) {
1362-
Array.from(_dependencies)
1363-
.filter(([key, value]) => isNodeTypeIncludesFunction(context, value.references[0].identifier))
1364-
.forEach(([key, value]) => {
1365-
// CHANGE V3
1366-
1367-
let _node = value.references[0].identifier
1368-
if (!_node.name.endsWith('__global')) {
1369-
let currentLine = _node.loc.start.line
1370-
let prevLineText = context.getSourceCode().getLines()[currentLine - 2]
1371-
const existingComment = prevLineText?.includes(LINT_COMMENT_PREFIX) ? prevLineText : ''
1372-
const newFlag = `${_node.name} - ${SELECTOR_LOCAL_FUNCTION_DEPENDECY_COMMENT}`
1373-
const newComment = getUpdatedLintComment(newFlag, existingComment)
1374-
if (!prevLineText?.includes(newFlag)) {
1375-
context.report({
1376-
node: _node,
1377-
messageId: 'will be noted as local dependency causing a selector to not be cached globally',
1378-
fix(fixer) {
1379-
return prevLineText.includes(LINT_COMMENT_PREFIX)
1380-
? fixer.replaceTextRange(getPrevLineRange(context, _node), `${newComment}`)
1381-
: fixer.insertTextBeforeRange(
1382-
getCurrentLineRange(context, _node),
1383-
`${newComment}\n`
1384-
)
1385-
},
1386-
})
1387-
}
1388-
}
1389-
// else if (prevLineText?.includes('function dependency')) {
1390-
// console.log('2')
1391-
// context.report({
1392-
// node: _node,
1393-
// messageId: 'will be noted as local dependency causing a selector to not be cached globally',
1394-
// fix(fixer) {
1395-
// return fixer.removeRange(getPrevLineRange(context, _node))
1396-
// },
1397-
// })
1398-
// }
1399-
})
1400-
}
1358+
// if (isHookIncludeAllDeps && functionDeps.size > 0) {
1359+
// Array.from(_dependencies)
1360+
// .filter(([key, value]) => isNodeTypeIncludesFunction(context, value.references[0].identifier))
1361+
// .forEach(([key, value]) => {
1362+
// // CHANGE V3
1363+
1364+
// // let _node = value.references[0].identifier
1365+
// // if (!_node.name.endsWith('__global')) {
1366+
// // let currentLine = _node.loc.start.line
1367+
// // let prevLineText = context.getSourceCode().getLines()[currentLine - 2]
1368+
// // const existingComment = prevLineText?.includes(LINT_COMMENT_PREFIX) ? prevLineText : ''
1369+
// // const newFlag = `${_node.name} - ${SELECTOR_LOCAL_FUNCTION_DEPENDECY_COMMENT}`
1370+
// // const newComment = getUpdatedLintComment(newFlag, existingComment)
1371+
// // if (!prevLineText?.includes(newFlag)) {
1372+
// // context.report({
1373+
// // node: _node,
1374+
// // messageId: 'will be noted as local dependency causing a selector to not be cached globally',
1375+
// // fix(fixer) {
1376+
// // return prevLineText.includes(LINT_COMMENT_PREFIX)
1377+
// // ? fixer.replaceTextRange(getPrevLineRange(context, _node), `${newComment}`)
1378+
// // : fixer.insertTextBeforeRange(
1379+
// // getCurrentLineRange(context, _node),
1380+
// // `${newComment}\n`
1381+
// // )
1382+
// // },
1383+
// // })
1384+
// // }
1385+
// // }
1386+
// // else if (prevLineText?.includes('function dependency')) {
1387+
// // console.log('2')
1388+
// // context.report({
1389+
// // node: _node,
1390+
// // messageId: 'will be noted as local dependency causing a selector to not be cached globally',
1391+
// // fix(fixer) {
1392+
// // return fixer.removeRange(getPrevLineRange(context, _node))
1393+
// // },
1394+
// // })
1395+
// // }
1396+
// })
1397+
// }
14011398

14021399
// console.log({
14031400
// realfndep: functionDeps.get('realfn')?.references?.[0],

0 commit comments

Comments
 (0)