Skip to content

Commit 060716f

Browse files
committed
feature: @putout/plugin-optional-chaining: convert to ESM
1 parent 02c83c1 commit 060716f

File tree

21 files changed

+57
-90
lines changed

21 files changed

+57
-90
lines changed

packages/plugin-new/lib/add-missing/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 = () => `Add missing operator 'new'`;
22

3-
module.exports.report = () => `Add missing operator 'new'`;
4-
5-
module.exports.replace = () => ({
3+
export const replace = () => ({
64
'Set(__args)': 'new Set(__args)',
75
'WeakSet(__args)': 'new WeakSet(__args)',
86
'Map(__args)': 'new Map(__args)',

packages/plugin-new/lib/add-missing/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 removeUselessNew from './index.js';
23

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

packages/plugin-new/lib/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict';
1+
import * as addMissing from './add-missing/index.js';
2+
import * as removeUseless from './remove-useless/index.js';
23

3-
const addMissing = require('./add-missing');
4-
const removeUseless = require('./remove-useless');
5-
6-
module.exports.rules = {
4+
export const rules = {
75
'add-missing': addMissing,
86
'remove-useless': removeUseless,
97
};

packages/plugin-new/lib/remove-useless/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
'use strict';
1+
import {types} from 'putout';
22

3-
const {types} = require('putout');
43
const {objectExpression} = types;
54

6-
module.exports.report = () => `Avoid useless operator 'new'`;
5+
export const report = () => `Avoid useless operator 'new'`;
76

8-
module.exports.replace = () => ({
7+
export const replace = () => ({
98
'new new __a': 'new __a',
109
'new Error(__args)': 'Error(__args)',
1110
'new TypeError(__args)': 'TypeError(__args)',

packages/plugin-new/lib/remove-useless/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 removeUselessNew from './index.js';
23

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

packages/plugin-new/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@putout/plugin-new",
33
"version": "3.0.1",
4-
"type": "commonjs",
4+
"type": "module",
55
"author": "coderaiser <[email protected]> (https://github.com/coderaiser)",
66
"description": "🐊Putout plugin adds ability to remove useless and add missing operator 'new'",
77
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-new#readme",

packages/plugin-new/test/new.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 pluginNew from '../lib/index.js';
23

3-
const {createTest} = require('@putout/test');
4-
const pluginNew = require('..');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
plugins: [
86
['new', pluginNew],
97
],
File renamed without changes.
File renamed without changes.

packages/plugin-optional-chaining/lib/convert-logical-assign-to-optional/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 optional expression ('a?.b = c') instead of 'condition' ('a && a.b = c')`;
22

3-
module.exports.report = () => `Use optional expression ('a?.b = c') instead of 'condition' ('a && a.b = c')`;
4-
5-
module.exports.replace = () => ({
3+
export const replace = () => ({
64
'if (__a) {__a.__b = __c}': '__a?.__b = __c',
75
'if (__a) __a.__b = __c': '__a?.__b = __c',
86
'__a && (__a.__b = __c)': '__a?.__b = __c',

0 commit comments

Comments
 (0)