Skip to content

Commit 9158c6b

Browse files
committed
feature: @putout/plugin-math: convert to ESM
1 parent fa406a9 commit 9158c6b

File tree

17 files changed

+46
-75
lines changed

17 files changed

+46
-75
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
1+
export const report = () => `Use operator '**' instead of 'Math.pow()'`;
22

3-
module.exports.report = () => `Use operator '**' instead of 'Math.pow()'`;
4-
5-
module.exports.replace = () => ({
3+
export const replace = () => ({
64
'Math.pow(__a, __b)': '__a ** __b',
75
'__a * __a': '__a ** 2',
86
});

packages/plugin-math/lib/apply-exponentiation/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as convertMathPow from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const convertMathPow = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['apply-exponentiation', convertMathPow],
97
],
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
'use strict';
1+
export const report = () => `Use '*' instead of 'Math.imul()'`;
22

3-
module.exports.report = () => `Use '*' instead of 'Math.imul()'`;
4-
5-
module.exports.replace = () => ({
3+
export const replace = () => ({
64
'Math.imul(__a, __b)': '__a * __b',
75
});

packages/plugin-math/lib/apply-multiplication/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const plugin = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['math/apply-multiplication', plugin],
97
],

packages/plugin-math/lib/apply-numeric-separators/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
'use strict';
1+
export const report = () => `Numeric separators should be used`;
22

3-
module.exports.report = () => `Numeric separators should be used`;
4-
5-
module.exports.fix = ({node}) => {
3+
export const fix = ({node}) => {
64
const {raw} = node;
75

86
node.raw = split(raw);
97
node.value = split(raw);
108
};
119

12-
module.exports.traverse = ({push}) => ({
10+
export const traverse = ({push}) => ({
1311
NumericLiteral(path) {
1412
const {node} = path;
1513

packages/plugin-math/lib/apply-numeric-separators/index.spec.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as webpack from '@putout/plugin-webpack';
3+
import * as applyNumericSeparators from './index.js';
24

3-
const {createTest} = require('@putout/test');
4-
5-
const webpack = require('@putout/plugin-webpack');
6-
const applyNumericSeparators = require('.');
7-
8-
const test = createTest(__dirname, {
5+
const test = createTest(import.meta.url, {
96
plugins: [
107
['math/apply-numeric-separators', applyNumericSeparators],
118
],

packages/plugin-math/lib/convert-sqrt-to-hypot/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
1+
export const report = () => `Use 'Math.hypot()' instead of 'Math.sqrt()'`;
22

3-
module.exports.report = () => `Use 'Math.hypot()' instead of 'Math.sqrt()'`;
4-
5-
module.exports.replace = () => ({
3+
export const replace = () => ({
64
'Math.sqrt(__a ** 2)': 'Math.hypot(__a)',
75
'Math.sqrt(__a ** 2 + __b ** 2)': 'Math.hypot(__a, __b)',
86
'Math.sqrt(__a ** 2 + __b ** 2 + __c ** 2)': 'Math.hypot(__a, __b, __c)',

packages/plugin-math/lib/convert-sqrt-to-hypot/index.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import {createTest} from '@putout/test';
2+
import * as convertMathPow from './index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const convertMathPow = require('.');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['math/convert-sqrt-to-hypot', convertMathPow],
97
],

0 commit comments

Comments
 (0)