Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Dec 11, 2020
1 parent 43f60a1 commit 80efc44
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions rules/prefer-date-now.js
Expand Up @@ -8,7 +8,7 @@ const MESSAGE_ID_NUMBER = 'prefer-date-now-over-number-data-object';
const messages = {
[MESSAGE_ID_DEFAULT]: 'Prefer `Date.now()` over `new Date()`.',
[MESSAGE_ID_METHOD]: 'Prefer `Date.now()` over `Date#{{method}}()`.',
[MESSAGE_ID_NUMBER]: 'Prefer `Date.now()` over `Number(new Date())`.',
[MESSAGE_ID_NUMBER]: 'Prefer `Date.now()` over `Number(new Date())`.'
};

const createNewDateSelector = path => {
Expand All @@ -29,7 +29,7 @@ const methodsSelector = [
names: ['getTime', 'valueOf'],
length: 0
}),
createNewDateSelector('callee.object'),
createNewDateSelector('callee.object')
].join('');
const constructorsSelector = [
'CallExpression',
Expand Down Expand Up @@ -60,11 +60,11 @@ const binaryExpressionSelector = [

const create = context => {
const report = (node, problem) => context.report({
node,
messageId: MESSAGE_ID_DEFAULT,
fix: fixer => fixer.replaceText(node, 'Date.now()'),
...problem
})
node,
messageId: MESSAGE_ID_DEFAULT,
fix: fixer => fixer.replaceText(node, 'Date.now()'),
...problem
});

return {
[methodsSelector](node) {
Expand All @@ -79,7 +79,7 @@ const create = context => {
const {name} = node.callee;
if (name === 'Number') {
report(node, {
messageId: MESSAGE_ID_NUMBER,
messageId: MESSAGE_ID_NUMBER
});
} else {
report(node.arguments[0]);
Expand All @@ -94,7 +94,7 @@ const create = context => {
[binaryExpressionSelector](node) {
report(node);
}
}
};
};

const schema = [];
Expand Down

0 comments on commit 80efc44

Please sign in to comment.