mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-31 09:41:46 +00:00
021612414c
* fix(lint): use `parseInt` over `Number` As a code review comment that comes up every so often, we can add a linting rule to enforce this check. This also fixes any existing usages. As this could be breaking, we can release it as a `fix`. Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io> * fixup! fix(lint): use `parseInt` over `Number` * fixup! fix(lint): use `parseInt` over `Number` --------- Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
32 lines
741 B
TypeScript
32 lines
741 B
TypeScript
import { defineRule } from '@oxlint/plugins';
|
|
|
|
export default defineRule({
|
|
meta: {
|
|
type: 'problem',
|
|
messages: {
|
|
noNumberConstructor:
|
|
"Use parseInt(x, 10) instead of the 'Number' constructor.",
|
|
},
|
|
},
|
|
createOnce(context) {
|
|
return {
|
|
CallExpression(node) {
|
|
if (
|
|
node.callee.type === 'Identifier' &&
|
|
node.callee.name === 'Number'
|
|
) {
|
|
context.report({ node, messageId: 'noNumberConstructor' });
|
|
}
|
|
},
|
|
NewExpression(node) {
|
|
if (
|
|
node.callee.type === 'Identifier' &&
|
|
node.callee.name === 'Number'
|
|
) {
|
|
context.report({ node, messageId: 'noNumberConstructor' });
|
|
}
|
|
},
|
|
};
|
|
},
|
|
});
|