eslint-plugin-putout 29.4.0 → 30.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/lib/index.js +0 -1
- package/lib/plugin.js +0 -2
- package/package.json +4 -8
- package/lib/no-unresolved/index.js +0 -79
package/README.md
CHANGED
|
@@ -122,7 +122,6 @@ Then configure the rules you want to use under the rules section.
|
|
|
122
122
|
|
|
123
123
|
### ESM
|
|
124
124
|
|
|
125
|
-
- ✅ [No unresolved](/packages/eslint-plugin-putout/lib/no-unresolved#readme)
|
|
126
125
|
- ✅ [Remove duplicate extension](/packages/eslint-plugin-putout/lib/remove-duplicate-extensions#readme)
|
|
127
126
|
- ✅ [Add newlines between specifiers](/packages/eslint-plugin-putout/lib/add-newlines-between-specifiers#readme)
|
|
128
127
|
|
package/lib/index.js
CHANGED
|
@@ -40,7 +40,6 @@ const putoutConfig = [{
|
|
|
40
40
|
'putout/remove-empty-specifiers': 'error',
|
|
41
41
|
'putout/objects-braces-inside-array': 'error',
|
|
42
42
|
'putout/object-property-newline': 'error',
|
|
43
|
-
'putout/no-unresolved': 'error',
|
|
44
43
|
'putout/remove-duplicate-extensions': 'error',
|
|
45
44
|
'putout/evaluate': 'error',
|
|
46
45
|
'putout/tape-add-newline-before-assertion': 'error',
|
package/lib/plugin.js
CHANGED
|
@@ -21,7 +21,6 @@ import * as removeEmptyNewlineAfterLastElement from './remove-empty-newline-afte
|
|
|
21
21
|
import * as removeEmptySpecifiers from './remove-empty-specifiers/index.js';
|
|
22
22
|
import * as objectsBracesInsideArray from './objects-braces-inside-array/index.js';
|
|
23
23
|
import * as objectPropertyNewline from './object-property-newline/index.js';
|
|
24
|
-
import * as noUnresolved from './no-unresolved/index.js';
|
|
25
24
|
import * as removeDuplicateExtensions from './remove-duplicate-extensions/index.js';
|
|
26
25
|
import * as evaluate from './evaluate/index.js';
|
|
27
26
|
import * as tapeAddNewlineBeforeAssertion from './tape-add-newline-before-assertion/index.js';
|
|
@@ -60,7 +59,6 @@ export const rules = {
|
|
|
60
59
|
'remove-empty-specifiers': createPlugin(removeEmptySpecifiers),
|
|
61
60
|
'objects-braces-inside-array': createPlugin(objectsBracesInsideArray),
|
|
62
61
|
'object-property-newline': createPlugin(objectPropertyNewline),
|
|
63
|
-
'no-unresolved': createPlugin(noUnresolved),
|
|
64
62
|
'remove-duplicate-extensions': createPlugin(removeDuplicateExtensions),
|
|
65
63
|
'evaluate': createPlugin(evaluate),
|
|
66
64
|
'tape-add-newline-before-assertion': createPlugin(tapeAddNewlineBeforeAssertion),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "30.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ESLint plugin for 🐊Putout",
|
|
6
6
|
"release": false,
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@putout/engine-parser": "^15.0.1",
|
|
45
45
|
"@putout/eslint": "^5.0.0",
|
|
46
46
|
"@putout/eslint-config": "^13.0.0",
|
|
47
|
-
"@putout/eslint-flat": "^
|
|
47
|
+
"@putout/eslint-flat": "^4.0.0",
|
|
48
48
|
"@stylistic/eslint-plugin": "~5.2.0 || > 5.3.1",
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
|
50
50
|
"@typescript-eslint/parser": "^8.3.0",
|
|
@@ -73,12 +73,8 @@
|
|
|
73
73
|
"supertape": "^12.0.0"
|
|
74
74
|
},
|
|
75
75
|
"imports": {
|
|
76
|
-
"#typescript-eslint/parser":
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
"#babel/eslint-parser/experimental-worker": {
|
|
80
|
-
"default": "./eslint-v10/babel.js"
|
|
81
|
-
}
|
|
76
|
+
"#typescript-eslint/parser": "./eslint-v10/ts.js",
|
|
77
|
+
"#babel/eslint-parser/experimental-worker": "./eslint-v10/babel.js"
|
|
82
78
|
},
|
|
83
79
|
"engines": {
|
|
84
80
|
"node": ">=22"
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import process from 'node:process';
|
|
2
|
-
import {accessSync} from 'node:fs';
|
|
3
|
-
import {
|
|
4
|
-
extname,
|
|
5
|
-
dirname,
|
|
6
|
-
join,
|
|
7
|
-
} from 'node:path';
|
|
8
|
-
import {createRequire} from 'node:module';
|
|
9
|
-
import {tryCatch} from 'try-catch';
|
|
10
|
-
|
|
11
|
-
const require = createRequire(import.meta.url);
|
|
12
|
-
const cwd = process.cwd();
|
|
13
|
-
|
|
14
|
-
const RELATIVE = '\\.\\.?\\/?';
|
|
15
|
-
const isRelativeStart = (a) => RegExp(`^${RELATIVE}`).test(a);
|
|
16
|
-
const isRelativeEnd = (a) => RegExp(`${RELATIVE}$`).test(a);
|
|
17
|
-
const getDir = (a) => a === '<input>' ? cwd : dirname(a);
|
|
18
|
-
const getValue = ({source}) => source?.value;
|
|
19
|
-
|
|
20
|
-
export const category = 'errors';
|
|
21
|
-
export const report = () => 'Always add an extension to relative imports';
|
|
22
|
-
export const include = () => [
|
|
23
|
-
'ImportDeclaration',
|
|
24
|
-
'ImportExpression',
|
|
25
|
-
'ExportAllDeclaration',
|
|
26
|
-
'ExportNamedDeclaration',
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
export const fix = ({node, text, filename}) => {
|
|
30
|
-
const value = getValue(node);
|
|
31
|
-
const dir = getDir(filename);
|
|
32
|
-
|
|
33
|
-
const resolved = resolveSource({
|
|
34
|
-
dir,
|
|
35
|
-
value,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return text.replace(value, resolved);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const filter = ({node}) => {
|
|
42
|
-
const value = getValue(node);
|
|
43
|
-
|
|
44
|
-
if (!value || value.endsWith('.js'))
|
|
45
|
-
return false;
|
|
46
|
-
|
|
47
|
-
if (!isRelativeStart(value))
|
|
48
|
-
return false;
|
|
49
|
-
|
|
50
|
-
return !extname(value);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function resolveSource({dir, value}) {
|
|
54
|
-
if (isRelativeEnd(value)) {
|
|
55
|
-
const name = join(dir, value, 'package.json');
|
|
56
|
-
const [error, info] = tryCatch(require, name);
|
|
57
|
-
|
|
58
|
-
if (!error)
|
|
59
|
-
return join(value, info.main);
|
|
60
|
-
|
|
61
|
-
return `${value}/index.js`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (const ext of ['js', 'mjs', 'cjs']) {
|
|
65
|
-
const name = join(dir, `${value}.${ext}`);
|
|
66
|
-
const [error] = tryCatch(accessSync, name);
|
|
67
|
-
|
|
68
|
-
if (!error)
|
|
69
|
-
return `${value}.${ext}`;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const name = join(dir, value, `index.js`);
|
|
73
|
-
const [error] = tryCatch(accessSync, name);
|
|
74
|
-
|
|
75
|
-
if (!error)
|
|
76
|
-
return `${value}/index.js`;
|
|
77
|
-
|
|
78
|
-
return `${value}.js`;
|
|
79
|
-
}
|