MCPcopy
hub / github.com/vercel/next.js / checkTypos

Function checkTypos

packages/eslint-plugin-next/src/rules/no-typos.ts:54–72  ·  view source on GitHub ↗
(node, name)

Source from the content-addressed store, hash-verified

52
53 create(context) {
54 function checkTypos(node, name) {
55 if (NEXT_EXPORT_FUNCTIONS.includes(name)) {
56 return
57 }
58
59 const potentialTypos = NEXT_EXPORT_FUNCTIONS.map((o) => ({
60 option: o,
61 distance: minDistance(o, name),
62 }))
63 .filter(({ distance }) => distance <= THRESHOLD && distance > 0)
64 .sort((a, b) => a.distance - b.distance)
65
66 if (potentialTypos.length) {
67 context.report({
68 node,
69 message: `${name} may be a typo. Did you mean ${potentialTypos[0].option}?`,
70 })
71 }
72 }
73 return {
74 ExportNamedDeclaration(node) {
75 const page = context.filename.split('pages', 2)[1]

Callers 1

ExportNamedDeclarationFunction · 0.85

Calls 6

includesMethod · 0.80
reportMethod · 0.80
minDistanceFunction · 0.70
sortMethod · 0.45
filterMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected