-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix broken rule, set Angular/Typescript as optionalPeerDeps #32
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
*/ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const path = require('node:path'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New recommended way to refer to builtin node packages. |
||
|
||
const clean = (value) => (value ?? '').toLowerCase().replace(/[^a-z0-9]+/g, ''); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
*/ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const path = require('node:path'); | ||
|
||
const isUnderPath = (folderPath, targetPath) => { | ||
const relative = path.relative(folderPath, targetPath); | ||
|
@@ -87,8 +87,8 @@ module.exports = { | |
buildReport( | ||
node, | ||
featureFolderIndex !== -1 ? featureFolders[featureFolderIndex] : sharedFolders[sharedFolderIndex], | ||
otherFeatureFolders[featureFolderImportedIndex] | ||
) | ||
otherFeatureFolders[featureFolderImportedIndex], | ||
), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added and ran prettier |
||
); | ||
} | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
*/ | ||
'use strict'; | ||
|
||
const ts = require('typescript'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This missing import caused this rule to error if it were ever used. |
||
const moreInfo = `More info: https://github.com/criteo/eslint-plugin-criteo#no-indexed-access-on-enums`; | ||
|
||
module.exports = { | ||
|
Fuzzball24816 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,14 @@ module.exports = { | |
type: 'problem', | ||
fixable: 'code', | ||
schema: [], | ||
messages: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes the one existing lint error. |
||
objectMessage: `Creating a new object by spreading the previous accumulator at every iteration of a .reduce() call has O(n^2) time & spatial complexity. If possible, make this O(n) by assigning to the existing accumulator or use mappedBy() or mappedByUnique() instead of .reduce(). ${moreInfo}`, | ||
arrayMessage: `Creating a new array by spreading the previous accumulator at every iteration of a .reduce() call has O(n^2) time & spatial complexity. If possible, make this O(n) by pushing to the existing accumulator instead. ${moreInfo}`, | ||
}, | ||
}, | ||
create: function (context) { | ||
return { | ||
'CallExpression:has([callee.property.name=reduce])[arguments] > ArrowFunctionExpression'(node) { | ||
const objectMessage = `Creating a new object by spreading the previous accumulator at every iteration of a .reduce() call has O(n^2) time & spatial complexity. If possible, make this O(n) by assigning to the existing accumulator or use mappedBy() or mappedByUnique() instead of .reduce(). ${moreInfo}`; | ||
const arrayMessage = `Creating a new array by spreading the previous accumulator at every iteration of a .reduce() call has O(n^2) time & spatial complexity. If possible, make this O(n) by pushing to the existing accumulator instead. ${moreInfo}`; | ||
|
||
// only fetch the source code if getNodeText is called, and only fetch it once if we do | ||
const sourceCode = { | ||
_source: null, | ||
|
@@ -29,10 +30,10 @@ module.exports = { | |
}, | ||
}; | ||
|
||
const getReportConfig = (spreadNode, fix, message) => ({ | ||
const getReportConfig = (spreadNode, fix, messageId) => ({ | ||
node: spreadNode.argument, | ||
loc: spreadNode.loc, | ||
message, | ||
messageId, | ||
fix, | ||
}); | ||
|
||
|
@@ -83,7 +84,7 @@ module.exports = { | |
const nonSpreadPropertyTexts = expression.properties | ||
.filter((o, i) => i != spreadIndex) | ||
.map( | ||
(o) => `${arrowFnFirstArgName}[${sourceCode.getNodeText(o.key)}] = ${sourceCode.getNodeText(o.value)}` | ||
(o) => `${arrowFnFirstArgName}[${sourceCode.getNodeText(o.key)}] = ${sourceCode.getNodeText(o.value)}`, | ||
); | ||
if (nonSpreadPropertyTexts.length <= 0) return undefined; | ||
|
||
|
@@ -92,7 +93,7 @@ module.exports = { | |
const fix = (fixer) => [fixer.replaceTextRange(arrowFn.range, newArrowFnText)]; | ||
return fix; | ||
}; | ||
const reportConfig = getReportConfig(spreadNode, getObjectFix(), objectMessage); | ||
const reportConfig = getReportConfig(spreadNode, getObjectFix(), 'objectMessage'); | ||
return context.report(reportConfig); | ||
} else if (expression.type === 'ArrayExpression') { | ||
let spreadIndex = null; | ||
|
@@ -130,13 +131,13 @@ module.exports = { | |
if (!nonSpreadElementTexts || nonSpreadElementTexts.length <= 0) return undefined; | ||
|
||
const bodyText = `${arrowFnFirstArgName}.push(${nonSpreadElementTexts.join( | ||
', ' | ||
', ', | ||
)}); return ${arrowFnFirstArgName};`; | ||
const newArrowFnText = `(${paramsText}) => { ${bodyText} }`; | ||
const fix = (fixer) => [fixer.replaceTextRange(arrowFn.range, newArrowFnText)]; | ||
return fix; | ||
}; | ||
const reportConfig = getReportConfig(spreadNode, getArrayFix(), arrayMessage); | ||
const reportConfig = getReportConfig(spreadNode, getArrayFix(), 'arrayMessage'); | ||
return context.report(reportConfig); | ||
} | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were added by my local markdown linter. Looks like it's shorthand for a URL. https://www.markdownguide.org/basic-syntax/#urls-and-email-addresses
Github seems to render them correctly anyway, but it might as well be correct.