eslint-plugin-putout 28.0.5 → 28.2.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/eslint-v10/babel.js +107 -0
- package/eslint-v10/ts.js +106 -0
- package/lib/long-properties-destructuring/index.js +6 -0
- package/lib/markdown.mjs +1 -1
- package/lib/ts.mjs +1 -1
- package/package.json +13 -3
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Wrapper around @babel-eslint/parser to make it work with ESLint v10.
|
|
3
|
+
* @author Milos Djermanovic
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
//-----------------------------------------------------------------------------
|
|
9
|
+
// Requirements
|
|
10
|
+
//-----------------------------------------------------------------------------
|
|
11
|
+
const eslintScope = require('eslint-scope');
|
|
12
|
+
|
|
13
|
+
const babelESLintParser = require('@babel/eslint-parser/experimental-worker');
|
|
14
|
+
|
|
15
|
+
//------------------------------------------------------------------------------
|
|
16
|
+
// Type Definitions
|
|
17
|
+
//------------------------------------------------------------------------------
|
|
18
|
+
/** @typedef {import("eslint-scope").ScopeManager} ScopeManager */
|
|
19
|
+
//-----------------------------------------------------------------------------
|
|
20
|
+
// Helpers
|
|
21
|
+
//-----------------------------------------------------------------------------
|
|
22
|
+
/**
|
|
23
|
+
* Add global variables and resolve references to all global variables.
|
|
24
|
+
* @this {ScopeManager}
|
|
25
|
+
* @param {string[]} names Names of global variables to add.
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
function addGlobals(names) {
|
|
29
|
+
const [globalScope] = this.scopes;
|
|
30
|
+
|
|
31
|
+
for (const name of names) {
|
|
32
|
+
let variable = globalScope.set.get(name);
|
|
33
|
+
|
|
34
|
+
if (variable)
|
|
35
|
+
continue;
|
|
36
|
+
|
|
37
|
+
variable = new eslintScope.Variable(name, globalScope);
|
|
38
|
+
|
|
39
|
+
globalScope.variables.push(variable);
|
|
40
|
+
globalScope.set.set(name, variable);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* "through" contains all references which definitions cannot be found.
|
|
45
|
+
* Since we augment the global scope we need to update references
|
|
46
|
+
* and remove the ones that were added.
|
|
47
|
+
*
|
|
48
|
+
* Also, babel-eslint's scope manager doesn't resolve references
|
|
49
|
+
* to global `var` and `function` variables, so we'll resolve _all_
|
|
50
|
+
* references to variables that exist in the global scope.
|
|
51
|
+
*/
|
|
52
|
+
globalScope.through = globalScope.through.filter((reference) => {
|
|
53
|
+
const {name} = reference.identifier;
|
|
54
|
+
const variable = globalScope.set.get(name);
|
|
55
|
+
|
|
56
|
+
if (variable) {
|
|
57
|
+
/*
|
|
58
|
+
* Links the variable and the reference.
|
|
59
|
+
* And this reference is removed from `Scope#through`.
|
|
60
|
+
*/
|
|
61
|
+
reference.resolved = variable;
|
|
62
|
+
variable.references.push(reference);
|
|
63
|
+
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return true;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/*
|
|
71
|
+
* "implicit" contains information about implicit global variables (those created
|
|
72
|
+
* implicitly by assigning values to undeclared variables in non-strict code).
|
|
73
|
+
* Since we augment the global scope, we need to remove the ones that were added.
|
|
74
|
+
*/
|
|
75
|
+
const {implicit} = globalScope;
|
|
76
|
+
|
|
77
|
+
implicit.variables = implicit.variables.filter(({name}) => {
|
|
78
|
+
if (globalScope.set.has(name)) {
|
|
79
|
+
implicit.set.delete(name);
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return true;
|
|
84
|
+
});
|
|
85
|
+
// babel-eslint's scope manager doesn't produce "implicit.left"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//-----------------------------------------------------------------------------
|
|
89
|
+
// Exports
|
|
90
|
+
//-----------------------------------------------------------------------------
|
|
91
|
+
module.exports = {
|
|
92
|
+
...babelESLintParser,
|
|
93
|
+
parse(...args) {
|
|
94
|
+
const retv = babelESLintParser.parse(...args);
|
|
95
|
+
|
|
96
|
+
retv.scopeManager.addGlobals = addGlobals;
|
|
97
|
+
|
|
98
|
+
return retv;
|
|
99
|
+
},
|
|
100
|
+
parseForESLint(...args) {
|
|
101
|
+
const retv = babelESLintParser.parseForESLint(...args);
|
|
102
|
+
|
|
103
|
+
retv.scopeManager.addGlobals = addGlobals;
|
|
104
|
+
|
|
105
|
+
return retv;
|
|
106
|
+
},
|
|
107
|
+
};
|
package/eslint-v10/ts.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Wrapper around @typescript-eslint/parser to make it work with ESLint v10.
|
|
3
|
+
* @author Milos Djermanovic
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
//-----------------------------------------------------------------------------
|
|
9
|
+
// Requirements
|
|
10
|
+
//-----------------------------------------------------------------------------
|
|
11
|
+
const eslintScope = require('eslint-scope');
|
|
12
|
+
const typescriptESLintParser = require('@typescript-eslint/parser');
|
|
13
|
+
|
|
14
|
+
//------------------------------------------------------------------------------
|
|
15
|
+
// Type Definitions
|
|
16
|
+
//------------------------------------------------------------------------------
|
|
17
|
+
/** @typedef {import("eslint-scope").ScopeManager} ScopeManager */
|
|
18
|
+
//-----------------------------------------------------------------------------
|
|
19
|
+
// Helpers
|
|
20
|
+
//-----------------------------------------------------------------------------
|
|
21
|
+
/**
|
|
22
|
+
* Add global variables and resolve references to all global variables.
|
|
23
|
+
* @this {ScopeManager}
|
|
24
|
+
* @param {string[]} names Names of global variables to add.
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
function addGlobals(names) {
|
|
28
|
+
const [globalScope] = this.scopes;
|
|
29
|
+
|
|
30
|
+
for (const name of names) {
|
|
31
|
+
let variable = globalScope.set.get(name);
|
|
32
|
+
|
|
33
|
+
if (variable)
|
|
34
|
+
continue;
|
|
35
|
+
|
|
36
|
+
variable = new eslintScope.Variable(name, globalScope);
|
|
37
|
+
|
|
38
|
+
globalScope.variables.push(variable);
|
|
39
|
+
globalScope.set.set(name, variable);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* "through" contains all references which definitions cannot be found.
|
|
44
|
+
* Since we augment the global scope we need to update references
|
|
45
|
+
* and remove the ones that were added.
|
|
46
|
+
*
|
|
47
|
+
* Also, typescript-eslint's scope manager doesn't resolve references
|
|
48
|
+
* to global `var` and `function` variables, so we'll resolve _all_
|
|
49
|
+
* references to variables that exist in the global scope.
|
|
50
|
+
*/
|
|
51
|
+
globalScope.through = globalScope.through.filter((reference) => {
|
|
52
|
+
const {name} = reference.identifier;
|
|
53
|
+
const variable = globalScope.set.get(name);
|
|
54
|
+
|
|
55
|
+
if (variable) {
|
|
56
|
+
/*
|
|
57
|
+
* Links the variable and the reference.
|
|
58
|
+
* And this reference is removed from `Scope#through`.
|
|
59
|
+
*/
|
|
60
|
+
reference.resolved = variable;
|
|
61
|
+
variable.references.push(reference);
|
|
62
|
+
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return true;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* "implicit" contains information about implicit global variables (those created
|
|
71
|
+
* implicitly by assigning values to undeclared variables in non-strict code).
|
|
72
|
+
* Since we augment the global scope, we need to remove the ones that were added.
|
|
73
|
+
*/
|
|
74
|
+
const {implicit} = globalScope;
|
|
75
|
+
|
|
76
|
+
implicit.variables = implicit.variables.filter(({name}) => {
|
|
77
|
+
if (globalScope.set.has(name)) {
|
|
78
|
+
implicit.set.delete(name);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return true;
|
|
83
|
+
});
|
|
84
|
+
// typescript-eslint's scope manager doesn't produce "implicit.left"
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//-----------------------------------------------------------------------------
|
|
88
|
+
// Exports
|
|
89
|
+
//-----------------------------------------------------------------------------
|
|
90
|
+
module.exports = {
|
|
91
|
+
...typescriptESLintParser,
|
|
92
|
+
parse(...args) {
|
|
93
|
+
const retv = typescriptESLintParser.parse(...args);
|
|
94
|
+
|
|
95
|
+
retv.scopeManager.addGlobals = addGlobals;
|
|
96
|
+
|
|
97
|
+
return retv;
|
|
98
|
+
},
|
|
99
|
+
parseForESLint(...args) {
|
|
100
|
+
const retv = typescriptESLintParser.parseForESLint(...args);
|
|
101
|
+
|
|
102
|
+
retv.scopeManager.addGlobals = addGlobals;
|
|
103
|
+
|
|
104
|
+
return retv;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
@@ -5,6 +5,9 @@ const {isCorrectLoc} = require('../common');
|
|
|
5
5
|
const {
|
|
6
6
|
isImportDeclaration,
|
|
7
7
|
isForOfStatement,
|
|
8
|
+
isIdentifier,
|
|
9
|
+
isSpreadElement,
|
|
10
|
+
isRestElement,
|
|
8
11
|
} = types;
|
|
9
12
|
|
|
10
13
|
const parseOptions = (options) => {
|
|
@@ -76,6 +79,9 @@ module.exports.filter = ({node}, options) => {
|
|
|
76
79
|
|
|
77
80
|
function isCorrectPropertiesLength(properties, {maxLength}) {
|
|
78
81
|
for (const prop of properties) {
|
|
82
|
+
if (!isIdentifier(prop.key) && !isSpreadElement(prop) && !isRestElement(prop))
|
|
83
|
+
return true;
|
|
84
|
+
|
|
79
85
|
const {name} = prop.key || prop.argument;
|
|
80
86
|
|
|
81
87
|
if (name.length >= maxLength)
|
package/lib/markdown.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import parserOpts from '@putout/engine-parser/babel/options';
|
|
2
2
|
import parserPlugins from '@putout/engine-parser/babel/plugins';
|
|
3
|
-
import babel from '
|
|
3
|
+
import babel from '#babel/eslint-parser/experimental-worker';
|
|
4
4
|
import tsConfig from './ts.mjs';
|
|
5
5
|
import {jsx} from './jsx.mjs';
|
|
6
6
|
|
package/lib/ts.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {rules} from '@putout/eslint-config';
|
|
2
|
-
import parser from '@typescript-eslint/parser';
|
|
3
2
|
import tseslint from 'typescript-eslint';
|
|
4
3
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
5
4
|
import stylistic from '@stylistic/eslint-plugin';
|
|
5
|
+
import parser from '#typescript-eslint/parser';
|
|
6
6
|
import {jsx} from './jsx.mjs';
|
|
7
7
|
import * as plugin from './plugin.mjs';
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-putout",
|
|
3
|
-
"version": "28.0
|
|
3
|
+
"version": "28.2.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "ESLint plugin for 🐊Putout",
|
|
6
6
|
"release": false,
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"url": "git+https://github.com/coderaiser/putout.git"
|
|
13
13
|
},
|
|
14
14
|
"exports": {
|
|
15
|
-
".": "./lib/index.mjs"
|
|
15
|
+
".": "./lib/index.mjs",
|
|
16
|
+
"./babel": "./eslint-v10/babel.js"
|
|
16
17
|
},
|
|
17
18
|
"keywords": [
|
|
18
19
|
"putout",
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"eslint-plugin-n": "^17.0.0",
|
|
52
53
|
"eslint-plugin-putout": "^28.0.0",
|
|
53
54
|
"eslint-plugin-react": "^7.32.2",
|
|
55
|
+
"eslint-scope": "^9.0.0",
|
|
54
56
|
"globals": "^16.0.0",
|
|
55
57
|
"parse-import-specifiers": "^1.0.1",
|
|
56
58
|
"try-catch": "^3.0.0",
|
|
@@ -63,7 +65,7 @@
|
|
|
63
65
|
"@putout/plugin-eslint-plugin": "*",
|
|
64
66
|
"@putout/test": "^14.0.0",
|
|
65
67
|
"c8": "^10.0.0",
|
|
66
|
-
"eslint": "
|
|
68
|
+
"eslint": "v10.0.0-alpha.0",
|
|
67
69
|
"eslint-plugin-eslint-plugin": "^7.0.0",
|
|
68
70
|
"madrun": "^11.0.0",
|
|
69
71
|
"mocha": "^11.0.1",
|
|
@@ -71,6 +73,14 @@
|
|
|
71
73
|
"simport": "^1.2.0",
|
|
72
74
|
"supertape": "^11.0.3"
|
|
73
75
|
},
|
|
76
|
+
"imports": {
|
|
77
|
+
"#typescript-eslint/parser": {
|
|
78
|
+
"default": "./eslint-v10/ts.js"
|
|
79
|
+
},
|
|
80
|
+
"#babel/eslint-parser/experimental-worker": {
|
|
81
|
+
"default": "./eslint-v10/babel.js"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
74
84
|
"engines": {
|
|
75
85
|
"node": ">=20"
|
|
76
86
|
},
|