@stylistic/eslint-plugin-jsx
Advanced tools
Comparing version 2.7.2 to 2.8.0
'use strict'; | ||
var utils = require('./utils.js'); | ||
var jsxChildElementSpacing = require('./rules/jsx-child-element-spacing.js'); | ||
@@ -23,3 +24,2 @@ var jsxClosingBracketLocation = require('./rules/jsx-closing-bracket-location.js'); | ||
var jsxWrapMultilines = require('./rules/jsx-wrap-multilines.js'); | ||
var utils = require('./utils.js'); | ||
@@ -26,0 +26,0 @@ var rules = { |
'use strict'; | ||
var configs = require('./configs.js'); | ||
require('./rules/jsx-child-element-spacing.js'); | ||
require('./utils.js'); | ||
@@ -9,2 +8,3 @@ require('eslint-visitor-keys'); | ||
require('estraverse'); | ||
require('./rules/jsx-child-element-spacing.js'); | ||
require('./rules/jsx-closing-bracket-location.js'); | ||
@@ -11,0 +11,0 @@ require('./rules/jsx-closing-tag-location.js'); |
@@ -43,3 +43,3 @@ 'use strict'; | ||
fix(fixer) { | ||
const indent = Array(opening.loc.start.column + 1).join(" "); | ||
const indent = new Array(opening.loc.start.column + 1).join(" "); | ||
if (utils.isNodeFirstInLine(context, node)) { | ||
@@ -46,0 +46,0 @@ return fixer.replaceTextRange( |
@@ -123,3 +123,3 @@ 'use strict'; | ||
], | ||
Array(nestedIndent + 1).join(indentType === "space" ? " " : " ") | ||
new Array(nestedIndent + 1).join(indentType === "space" ? " " : " ") | ||
); | ||
@@ -126,0 +126,0 @@ } |
@@ -66,3 +66,3 @@ 'use strict'; | ||
function getFixerFunction(node, needed) { | ||
const indent = Array(needed + 1).join(indentChar); | ||
const indent = new Array(needed + 1).join(indentChar); | ||
if (node.type === "JSXText" || node.type === "Literal") { | ||
@@ -69,0 +69,0 @@ return function fix(fixer) { |
'use strict'; | ||
var utils = require('../utils.js'); | ||
var picomatch = require('picomatch'); | ||
var utils = require('../utils.js'); | ||
require('eslint-visitor-keys'); | ||
@@ -6,0 +6,0 @@ require('espree'); |
@@ -7,2 +7,26 @@ 'use strict'; | ||
function createAllConfigs(plugin, name, flat, filter) { | ||
const rules = Object.fromEntries( | ||
Object.entries(plugin.rules).filter( | ||
([key, rule]) => ( | ||
// Only include fixable rules | ||
rule.meta.fixable && !rule.meta.deprecated && key === rule.meta.docs.url.split("/").pop() && (!filter) | ||
) | ||
).map(([key]) => [`${name}/${key}`, 2]) | ||
); | ||
if (flat) { | ||
return { | ||
plugins: { | ||
[name]: plugin | ||
}, | ||
rules | ||
}; | ||
} else { | ||
return { | ||
plugins: [name], | ||
rules | ||
}; | ||
} | ||
} | ||
function isObjectNotArray(obj) { | ||
@@ -150,31 +174,2 @@ return typeof obj === "object" && obj != null && !Array.isArray(obj); | ||
function getVariable(variables, name) { | ||
return variables.find((variable) => variable.name === name); | ||
} | ||
function variablesInScope(context) { | ||
let scope = context.getScope(); | ||
let variables = scope.variables; | ||
while (scope.type !== "global") { | ||
scope = scope.upper; | ||
variables = scope.variables.concat(variables); | ||
} | ||
if (scope.childScopes.length) { | ||
variables = scope.childScopes[0].variables.concat(variables); | ||
if (scope.childScopes[0].childScopes.length) | ||
variables = scope.childScopes[0].childScopes[0].variables.concat(variables); | ||
} | ||
variables.reverse(); | ||
return variables; | ||
} | ||
function findVariableByName(context, name) { | ||
const variable = getVariable(variablesInScope(context), name); | ||
if (!variable || !variable.defs[0] || !variable.defs[0].node) | ||
return null; | ||
if (variable.defs[0].node.type === "TypeAlias") | ||
return variable.defs[0].node.right; | ||
if (variable.defs[0].type === "ImportBinding") | ||
return variable.defs[0].node; | ||
return variable.defs[0].node.init; | ||
} | ||
function traverse(ASTnode, visitor) { | ||
@@ -231,2 +226,31 @@ const opts = Object.assign({}, { | ||
function getVariable(variables, name) { | ||
return variables.find((variable) => variable.name === name); | ||
} | ||
function variablesInScope(context) { | ||
let scope = context.getScope(); | ||
let variables = scope.variables; | ||
while (scope.type !== "global") { | ||
scope = scope.upper; | ||
variables = scope.variables.concat(variables); | ||
} | ||
if (scope.childScopes.length) { | ||
variables = scope.childScopes[0].variables.concat(variables); | ||
if (scope.childScopes[0].childScopes.length) | ||
variables = scope.childScopes[0].childScopes[0].variables.concat(variables); | ||
} | ||
variables.reverse(); | ||
return variables; | ||
} | ||
function findVariableByName(context, name) { | ||
const variable = getVariable(variablesInScope(context), name); | ||
if (!variable || !variable.defs[0] || !variable.defs[0].node) | ||
return null; | ||
if (variable.defs[0].node.type === "TypeAlias") | ||
return variable.defs[0].node.right; | ||
if (variable.defs[0].type === "ImportBinding") | ||
return variable.defs[0].node; | ||
return variable.defs[0].node.init; | ||
} | ||
const COMPAT_TAG_REGEX = /^[a-z]/; | ||
@@ -312,26 +336,2 @@ function isDOMComponent(node) { | ||
function createAllConfigs(plugin, name, flat, filter) { | ||
const rules = Object.fromEntries( | ||
Object.entries(plugin.rules).filter( | ||
([key, rule]) => ( | ||
// Only include fixable rules | ||
rule.meta.fixable && !rule.meta.deprecated && key === rule.meta.docs.url.split("/").pop() && (!filter) | ||
) | ||
).map(([key]) => [`${name}/${key}`, 2]) | ||
); | ||
if (flat) { | ||
return { | ||
plugins: { | ||
[name]: plugin | ||
}, | ||
rules | ||
}; | ||
} else { | ||
return { | ||
plugins: [name], | ||
rules | ||
}; | ||
} | ||
} | ||
exports.createAllConfigs = createAllConfigs; | ||
@@ -338,0 +338,0 @@ exports.createRule = createRule; |
{ | ||
"name": "@stylistic/eslint-plugin-jsx", | ||
"type": "commonjs", | ||
"version": "2.7.2", | ||
"version": "2.8.0", | ||
"author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
@@ -61,3 +61,2 @@ "license": "MIT", | ||
"dependencies": { | ||
"@types/eslint": "^9.6.1", | ||
"eslint-visitor-keys": "^4.0.0", | ||
@@ -64,0 +63,0 @@ "espree": "^10.1.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
152671
- Removed@types/eslint@^9.6.1
- Removed@types/eslint@9.6.1(transitive)