@withfig/eslint-plugin-fig-linter
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -13,2 +13,3 @@ module.exports = { | ||
"conventional-descriptions": require("./rules/conventional-descriptions"), | ||
"no-default-value-props": require("./rules/no-default-value-props"), | ||
}, | ||
@@ -23,2 +24,3 @@ configs: { | ||
"@withfig/fig-linter/no-name-equals": "error", | ||
"@withfig/fig-linter/no-default-value-props": ["error", [{path: "options.[*].isRequired", defaultValue: false}, {path: "args.[*]?.isOptional", defaultValue: false}]], | ||
// TODO: Re-Enable Rule if we got a proper flag for that | ||
@@ -43,2 +45,1 @@ "@withfig/fig-linter/no-invalid-option": "off", | ||
}; | ||
{ | ||
"name": "@withfig/eslint-plugin-fig-linter", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "This is a eslint plugin which is tailored for fig specs", | ||
@@ -11,7 +11,6 @@ "main": "index.js", | ||
"author": "The fig team", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "660d34fc9db0ef73f4577df9b5bced19ba36993a" | ||
} | ||
} |
@@ -5,3 +5,3 @@ const PROBLEMES = { | ||
trailingWhitespaces: "no trailing whitespaces", | ||
uncapitalized: "first letter capitalized" | ||
uncapitalized: "first letter capitalized", | ||
}; | ||
@@ -12,10 +12,13 @@ | ||
type: "problem", | ||
fixable: "code" | ||
fixable: "code", | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
'ObjectExpression > Property[key.name="description"]'(node) { | ||
'ObjectExpression > Property[key.name="description"]': function (node) { | ||
const propValue = node.value; | ||
if (propValue.type === "Literal" && typeof propValue.value === "string") { | ||
let problems = []; | ||
if ( | ||
propValue.type === "Literal" && | ||
typeof propValue.value === "string" | ||
) { | ||
const problems = []; | ||
let newString = propValue.raw.slice(1, -1); // exclude the StringLiteral op but keep escapes | ||
@@ -42,13 +45,12 @@ if (newString.startsWith(" ")) { | ||
message: `Descriptions should have: ${problems.join(", ")}.`, | ||
fix: function (fixer) { | ||
const d = propValue.raw.slice(0, 1) // keep the original StringLiteral op | ||
fix(fixer) { | ||
const d = propValue.raw.slice(0, 1); // keep the original StringLiteral op | ||
return fixer.replaceText(propValue, d + newString + d); | ||
} | ||
}, | ||
}); | ||
} | ||
} | ||
} | ||
}, | ||
}; | ||
} | ||
}, | ||
}; | ||
@@ -17,5 +17,5 @@ function getNameProperty(object) { | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
'ObjectExpression > Property[key.type="Identifier"]'(node) { | ||
'ObjectExpression > Property[key.type="Identifier"]': function (node) { | ||
if (node.key.name === "options" || node.key.name === "subcommands") { | ||
@@ -22,0 +22,0 @@ const set = new Set(); |
@@ -6,3 +6,3 @@ module.exports = { | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
@@ -28,6 +28,6 @@ Property(node) { | ||
context.report({ | ||
node: node, | ||
node, | ||
message: | ||
"Empty arrays don't have any effect and can be omitted", | ||
fix: function (fixer) { | ||
fix(fixer) { | ||
const [start, end] = node.range; | ||
@@ -34,0 +34,0 @@ return fixer.removeRange([start, end + 1]); |
@@ -11,3 +11,3 @@ const INVALID_REGEXP = /(<|\[).*(>|\])/; | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
@@ -14,0 +14,0 @@ Property(node) { |
@@ -33,3 +33,3 @@ const DASH_CHAR = "-"; | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
@@ -36,0 +36,0 @@ Property(node) { |
@@ -7,3 +7,3 @@ const RM_RF_REGEXP = /rm \-(?:f(?:(?: \-)?r)?|r(?: \-f|f)?)/; | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
@@ -10,0 +10,0 @@ Property(node) { |
@@ -9,9 +9,9 @@ module.exports = { | ||
return { | ||
ExportDefaultDeclaration(node) { | ||
ExportDefaultDeclaration() { | ||
hasExport = true; | ||
}, | ||
'ExportSpecifier[exported.name="default"]'(node) { | ||
'ExportSpecifier[exported.name="default"]': function (node) { | ||
hasExport = true; | ||
}, | ||
"Program:exit"(node) { | ||
"Program:exit": function (node) { | ||
if (!hasExport) { | ||
@@ -18,0 +18,0 @@ context.report({ |
@@ -6,3 +6,3 @@ module.exports = { | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
@@ -19,3 +19,3 @@ Property(node) { | ||
message: "The name property must not include `=`", | ||
fix: function (fixer) { | ||
fix(fixer) { | ||
const [, end] = currentNode.range; | ||
@@ -22,0 +22,0 @@ return fixer.replaceTextRange([end - 2, end - 1], ""); |
@@ -6,5 +6,5 @@ module.exports = { | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
"ObjectExpression > Property"(node) { | ||
"ObjectExpression > Property": function (node) { | ||
const propName = node.key.name; | ||
@@ -20,5 +20,5 @@ const propValue = node.value; | ||
context.report({ | ||
node: node, | ||
node, | ||
message: `If \`${propName}\` is a single value it should not be enclosed in square brackets.`, | ||
fix: function (fixer) { | ||
fix(fixer) { | ||
const [wrapperStart, wrapperEnd] = propValue.range; | ||
@@ -25,0 +25,0 @@ // it doesn't take into account `[...elem]` |
@@ -6,3 +6,3 @@ module.exports = { | ||
}, | ||
create: function (context) { | ||
create(context) { | ||
return { | ||
@@ -25,7 +25,8 @@ Property(node) { | ||
context.report({ | ||
node: node, | ||
node, | ||
message: | ||
"The insertValue prop can be omitted if the value is the same as name", | ||
fix: function (fixer) { | ||
fix(fixer) { | ||
const [start, end] = node.range; | ||
// TODO: check if there is a comma after the prop before removing end + 1 | ||
return fixer.removeRange([start, end + 1]); | ||
@@ -32,0 +33,0 @@ }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
17976
14
0
505
1