Skip to content

Commit e71ea95

Browse files
committed
feature: @putout/plugin-eslint: convert to ESM
1 parent 83d6c4f commit e71ea95

File tree

66 files changed

+255
-367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+255
-367
lines changed

packages/plugin-eslint/.madrun.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
1+
import {run} from 'madrun';
22

3-
const {run} = require('madrun');
4-
5-
module.exports = {
3+
export default {
64
'test': () => `tape 'test/*.js' 'lib/**/*.spec.js'`,
75
'watch:test': async () => `nodemon -w lib -x "${await run('test')}"`,
86
'lint': () => `putout .`,

packages/plugin-eslint/.putout.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"rules": {
3-
"putout/apply-namespace-specifier": "off"
4-
},
52
"match": {
63
"*.md": {
74
"putout/convert-match-to-function": "off",
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import {safeAlign} from 'eslint-plugin-putout';
22
import {defineConfig} from 'eslint/config';
33

4-
export default defineConfig([
5-
safeAlign, {
6-
ignores: ['**/fixture'],
7-
},
8-
]);
4+
export default defineConfig([safeAlign, {}]);

packages/plugin-eslint/lib/add-putout/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
'use strict';
2-
3-
const {types, operator} = require('putout');
4-
const {
1+
import {types, operator} from 'putout';
2+
import {
53
getExtends,
64
getPlugins,
75
isExtends,
86
isPlugins,
9-
} = require('../get.js');
7+
} from '../get.js';
108

119
const {__json} = operator;
1210
const {stringLiteral} = types;
1311

14-
module.exports.report = () => `Add 'putout' to 'plugins' and 'extends'`;
12+
export const report = () => `Add 'putout' to 'plugins' and 'extends'`;
1513

16-
module.exports.match = () => ({
14+
export const match = () => ({
1715
[__json]: ({__object}) => {
1816
if (!isExtends(__object) || !isPlugins(__object))
1917
return false;
@@ -27,7 +25,7 @@ module.exports.match = () => ({
2725
},
2826
});
2927

30-
module.exports.replace = () => ({
28+
export const replace = () => ({
3129
[__json]: ({__object}, path) => {
3230
getExtends(__object).push(stringLiteral('putout:plugin/safe+align'));
3331
getPlugins(__object).push(stringLiteral('putout'));

packages/plugin-eslint/lib/add-putout/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('./index.js');
5-
6-
const test = createTest(__dirname, {
4+
const test = createTest(import.meta.url, {
75
'eslint/add-putout': plugin,
86
});
97

packages/plugin-eslint/lib/apply-create-eslint-config/index.js

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

3-
const {types, operator} = require('putout');
43
const {replaceWith} = operator;
54
const {isSpreadElement} = types;
65

7-
module.exports.report = () => `Use 'createESLintConfig()' instead of spread ('...')`;
6+
export const report = () => `Use 'createESLintConfig()' instead of spread ('...')`;
87

9-
module.exports.match = () => ({
8+
export const match = () => ({
109
'module.exports = __array': hasSpreads({
1110
selector: 'right.elements',
1211
}),
@@ -15,7 +14,7 @@ module.exports.match = () => ({
1514
}),
1615
});
1716

18-
module.exports.replace = () => ({
17+
export const replace = () => ({
1918
'module.exports = __array': extractSpreads({
2019
selector: 'right.elements',
2120
template: 'module.exports = createESLintConfig(__array)',

packages/plugin-eslint/lib/apply-create-eslint-config/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
['apply-create-eslint-config', plugin],
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 'defineConfig' instead of 'createESLintConfig'`;
22

3-
module.exports.report = () => `Use 'defineConfig' instead of 'createESLintConfig'`;
4-
5-
module.exports.replace = () => ({
3+
export const replace = () => ({
64
'createESLintConfig(__args)': 'defineConfig(__args)',
75
});

packages/plugin-eslint/lib/apply-define-config/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
['apply-define-config', plugin],
97
],

packages/plugin-eslint/lib/apply-dir-to-flat/index.js

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

3-
const {operator} = require('putout');
43
const {isESM} = operator;
54
const createName = (a) => isESM(a) ? 'import.meta.url' : '__dirname';
65

7-
module.exports.report = () => `Add '__dirname/import.meta.url' as first argument`;
6+
export const report = () => `Add '__dirname/import.meta.url' as first argument`;
87

9-
module.exports.replace = () => ({
8+
export const replace = () => ({
109
'matchToFlatDir(__a)': (vars, path) => {
1110
const name = createName(path);
1211
return `matchToFlatDir(${name}, __a)`;

0 commit comments

Comments
 (0)