eslint-plugin-react-form-fields
Advanced tools
Comparing version 1.1.6 to 1.1.7
"use strict"; | ||
/* DON'T EDIT THIS FILE. This is generated by 'scripts/lib/update-lib-configs-recommended.ts' */ | ||
module.exports = { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
plugins: ['react-form-fields'], | ||
@@ -5,0 +6,0 @@ rules: { |
"use strict"; | ||
/* DON'T EDIT THIS FILE. This is generated by 'scripts/lib/update-lib-index.ts' */ | ||
module.exports = { | ||
configs: { | ||
recommended: require('./configs/recommended'), | ||
}, | ||
rules: { | ||
'no-mix-controlled-with-uncontrolled': require('./rules/no-mix-controlled-with-uncontrolled'), | ||
'no-only-value-prop': require('./rules/no-only-value-prop'), | ||
'styled-no-mix-controlled-with-uncontrolled': require('./rules/styled-no-mix-controlled-with-uncontrolled'), | ||
'styled-no-only-value-prop': require('./rules/styled-no-only-value-prop'), | ||
}, | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.rules = exports.configs = void 0; | ||
const recommended_1 = __importDefault(require("./configs/recommended")); | ||
const no_mix_controlled_with_uncontrolled_1 = __importDefault(require("./rules/no-mix-controlled-with-uncontrolled")); | ||
const no_only_value_prop_1 = __importDefault(require("./rules/no-only-value-prop")); | ||
const styled_no_mix_controlled_with_uncontrolled_1 = __importDefault(require("./rules/styled-no-mix-controlled-with-uncontrolled")); | ||
const styled_no_only_value_prop_1 = __importDefault(require("./rules/styled-no-only-value-prop")); | ||
exports.configs = { | ||
recommended: recommended_1.default, | ||
}; | ||
exports.rules = { | ||
'no-mix-controlled-with-uncontrolled': no_mix_controlled_with_uncontrolled_1.default, | ||
'no-only-value-prop': no_only_value_prop_1.default, | ||
'styled-no-mix-controlled-with-uncontrolled': styled_no_mix_controlled_with_uncontrolled_1.default, | ||
'styled-no-only-value-prop': styled_no_only_value_prop_1.default, | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const jsx_ast_utils_1 = require("jsx-ast-utils"); | ||
@@ -14,3 +15,3 @@ const capitalize_1 = require("../utils/capitalize"); | ||
recommended: 'error', | ||
url: docsUrl_1.docsUrl('no-mix-controlled-with-uncontrolled'), | ||
url: (0, docsUrl_1.docsUrl)('no-mix-controlled-with-uncontrolled'), | ||
}, | ||
@@ -26,9 +27,9 @@ messages: { | ||
JSXElement(node) { | ||
const tagName = getTagName_1.getTagName(node); | ||
if (!isFormFieldTags_1.isFormFieldTags(node)) { | ||
const tagName = (0, getTagName_1.getTagName)(node); | ||
if (!(0, isFormFieldTags_1.isFormFieldTags)(node)) { | ||
return; | ||
} | ||
if (isCheckboxOrRadioInput_1.isCheckboxOrRadioInput(node)) { | ||
const hasCheckedProp = jsx_ast_utils_1.hasProp(node.openingElement.attributes, 'checked'); | ||
const hasDefaultCheckedProp = jsx_ast_utils_1.hasProp(node.openingElement.attributes, 'defaultChecked'); | ||
if ((0, isCheckboxOrRadioInput_1.isCheckboxOrRadioInput)(node)) { | ||
const hasCheckedProp = (0, jsx_ast_utils_1.hasProp)(node.openingElement.attributes, 'checked'); | ||
const hasDefaultCheckedProp = (0, jsx_ast_utils_1.hasProp)(node.openingElement.attributes, 'defaultChecked'); | ||
if (hasCheckedProp && hasDefaultCheckedProp) { | ||
@@ -40,3 +41,3 @@ context.report({ | ||
tagName, | ||
capitalizeTagName: capitalize_1.capitalize(tagName), | ||
capitalizeTagName: (0, capitalize_1.capitalize)(tagName), | ||
valueName: 'checked', | ||
@@ -48,4 +49,4 @@ defaultValueName: 'defaultChecked', | ||
} | ||
const hasValueProp = jsx_ast_utils_1.hasProp(node.openingElement.attributes, 'value'); | ||
const hasDefaultValueProp = jsx_ast_utils_1.hasProp(node.openingElement.attributes, 'defaultValue'); | ||
const hasValueProp = (0, jsx_ast_utils_1.hasProp)(node.openingElement.attributes, 'value'); | ||
const hasDefaultValueProp = (0, jsx_ast_utils_1.hasProp)(node.openingElement.attributes, 'defaultValue'); | ||
if (hasValueProp && hasDefaultValueProp) { | ||
@@ -57,3 +58,3 @@ context.report({ | ||
tagName, | ||
capitalizeTagName: capitalize_1.capitalize(tagName), | ||
capitalizeTagName: (0, capitalize_1.capitalize)(tagName), | ||
valueName: 'value', | ||
@@ -68,2 +69,2 @@ defaultValueName: 'defaultValue', | ||
}; | ||
module.exports = rule; | ||
exports.default = rule; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const jsx_ast_utils_1 = require("jsx-ast-utils"); | ||
@@ -13,3 +14,3 @@ const docsUrl_1 = require("../utils/docsUrl"); | ||
recommended: 'error', | ||
url: docsUrl_1.docsUrl('no-only-value-prop'), | ||
url: (0, docsUrl_1.docsUrl)('no-only-value-prop'), | ||
}, | ||
@@ -25,9 +26,9 @@ messages: { | ||
JSXElement(node) { | ||
if (!isFormFieldTags_1.isFormFieldTags(node) || isHiddenInput_1.isHiddenInput(node)) { | ||
if (!(0, isFormFieldTags_1.isFormFieldTags)(node) || (0, isHiddenInput_1.isHiddenInput)(node)) { | ||
return; | ||
} | ||
const hasOnChangeProp = jsx_ast_utils_1.hasProp(node.openingElement.attributes, 'onChange'); | ||
const hasReadOnlyProp = jsx_ast_utils_1.hasProp(node.openingElement.attributes, 'readOnly'); | ||
if (isCheckboxOrRadioInput_1.isCheckboxOrRadioInput(node)) { | ||
const hasCheckedProp = jsx_ast_utils_1.hasProp(node.openingElement.attributes, 'checked'); | ||
const hasOnChangeProp = (0, jsx_ast_utils_1.hasProp)(node.openingElement.attributes, 'onChange'); | ||
const hasReadOnlyProp = (0, jsx_ast_utils_1.hasProp)(node.openingElement.attributes, 'readOnly'); | ||
if ((0, isCheckboxOrRadioInput_1.isCheckboxOrRadioInput)(node)) { | ||
const hasCheckedProp = (0, jsx_ast_utils_1.hasProp)(node.openingElement.attributes, 'checked'); | ||
if (hasCheckedProp && !hasOnChangeProp && !hasReadOnlyProp) { | ||
@@ -44,3 +45,3 @@ context.report({ | ||
} | ||
const hasValueProp = jsx_ast_utils_1.hasProp(node.openingElement.attributes, 'value'); | ||
const hasValueProp = (0, jsx_ast_utils_1.hasProp)(node.openingElement.attributes, 'value'); | ||
if (hasValueProp && !hasOnChangeProp && !hasReadOnlyProp) { | ||
@@ -60,2 +61,2 @@ context.report({ | ||
}; | ||
module.exports = rule; | ||
exports.default = rule; |
@@ -5,6 +5,7 @@ "use strict"; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const makeRule_1 = require("../utils/makeRule"); | ||
const docsUrl_1 = require("../utils/docsUrl"); | ||
const no_mix_controlled_with_uncontrolled_1 = __importDefault(require("./no-mix-controlled-with-uncontrolled")); | ||
const styledRule = Object.assign(Object.assign({}, no_mix_controlled_with_uncontrolled_1.default), { meta: Object.assign(Object.assign({}, no_mix_controlled_with_uncontrolled_1.default.meta), { docs: Object.assign(Object.assign({}, no_mix_controlled_with_uncontrolled_1.default.meta.docs), { recommended: false, url: docsUrl_1.docsUrl('styled-no-mix-controlled-with-uncontrolled') }) }) }); | ||
module.exports = makeRule_1.makeRule(styledRule); | ||
const styledRule = Object.assign(Object.assign({}, no_mix_controlled_with_uncontrolled_1.default), { meta: Object.assign(Object.assign({}, no_mix_controlled_with_uncontrolled_1.default.meta), { docs: Object.assign(Object.assign({}, no_mix_controlled_with_uncontrolled_1.default.meta.docs), { recommended: false, url: (0, docsUrl_1.docsUrl)('styled-no-mix-controlled-with-uncontrolled') }) }) }); | ||
exports.default = (0, makeRule_1.makeRule)(styledRule); |
@@ -5,6 +5,7 @@ "use strict"; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const makeRule_1 = require("../utils/makeRule"); | ||
const docsUrl_1 = require("../utils/docsUrl"); | ||
const no_only_value_prop_1 = __importDefault(require("./no-only-value-prop")); | ||
const styledRule = Object.assign(Object.assign({}, no_only_value_prop_1.default), { meta: Object.assign(Object.assign({}, no_only_value_prop_1.default.meta), { docs: Object.assign(Object.assign({}, no_only_value_prop_1.default.meta.docs), { recommended: false, url: docsUrl_1.docsUrl('styled-no-only-value-prop') }) }) }); | ||
module.exports = makeRule_1.makeRule(styledRule); | ||
const styledRule = Object.assign(Object.assign({}, no_only_value_prop_1.default), { meta: Object.assign(Object.assign({}, no_only_value_prop_1.default.meta), { docs: Object.assign(Object.assign({}, no_only_value_prop_1.default.meta.docs), { recommended: false, url: (0, docsUrl_1.docsUrl)('styled-no-only-value-prop') }) }) }); | ||
exports.default = (0, makeRule_1.makeRule)(styledRule); |
@@ -8,3 +8,3 @@ "use strict"; | ||
TaggedTemplateExpression(node) { | ||
const scName = styledJSX_1.getStyledComponentName(node); | ||
const scName = (0, styledJSX_1.getStyledComponentName)(node); | ||
if (!scName) | ||
@@ -14,3 +14,3 @@ return; | ||
let tag = ''; | ||
if (styledJSX_1.isStyledTags(node)) { | ||
if ((0, styledJSX_1.isStyledTags)(node)) { | ||
tag = | ||
@@ -28,3 +28,3 @@ (node.tag.type === experimental_utils_1.AST_NODE_TYPES.MemberExpression && | ||
// styled('div')`` | ||
if (styledJSX_1.isCreateStyledTags(node)) { | ||
if ((0, styledJSX_1.isCreateStyledTags)(node)) { | ||
tag = | ||
@@ -44,3 +44,3 @@ (node.tag.type === experimental_utils_1.AST_NODE_TYPES.CallExpression && | ||
// styled(Component)`` | ||
if (styledJSX_1.isCreateStyledComponent(node)) { | ||
if ((0, styledJSX_1.isCreateStyledComponent)(node)) { | ||
const ancestorScName = node.tag.type === experimental_utils_1.AST_NODE_TYPES.CallExpression && | ||
@@ -57,3 +57,3 @@ node.tag.arguments[0].type === experimental_utils_1.AST_NODE_TYPES.Identifier && | ||
// styled.div.attrs(...)`` | ||
if (styledJSX_1.isStyledTagsWithAttrs(node)) { | ||
if ((0, styledJSX_1.isStyledTagsWithAttrs)(node)) { | ||
tag = | ||
@@ -66,3 +66,3 @@ (node.tag.type === experimental_utils_1.AST_NODE_TYPES.CallExpression && | ||
''; | ||
attrs = styledJSX_1.getAttrsProperties(node); | ||
attrs = (0, styledJSX_1.getAttrsProperties)(node); | ||
styledComponents[scName] = { | ||
@@ -75,3 +75,3 @@ name: scName, | ||
} | ||
if (styledJSX_1.isCreateStyledTagsWithAttrs(node)) { | ||
if ((0, styledJSX_1.isCreateStyledTagsWithAttrs)(node)) { | ||
tag = | ||
@@ -85,3 +85,3 @@ (node.tag.type === experimental_utils_1.AST_NODE_TYPES.CallExpression && | ||
''; | ||
attrs = styledJSX_1.getAttrsProperties(node); | ||
attrs = (0, styledJSX_1.getAttrsProperties)(node); | ||
styledComponents[scName] = { | ||
@@ -95,3 +95,3 @@ name: scName, | ||
// styled(Component).attrs(...)`` | ||
if (styledJSX_1.isCreateStyledComponentWithAttrs(node)) { | ||
if ((0, styledJSX_1.isCreateStyledComponentWithAttrs)(node)) { | ||
const ancestorScName = node.tag.type === experimental_utils_1.AST_NODE_TYPES.CallExpression && | ||
@@ -106,3 +106,3 @@ node.tag.callee.type === experimental_utils_1.AST_NODE_TYPES.MemberExpression && | ||
tag = styledComponents[ancestorScName].tag; | ||
attrs = styledComponents[ancestorScName].attrs.concat(styledJSX_1.getAttrsProperties(node)); | ||
attrs = styledComponents[ancestorScName].attrs.concat((0, styledJSX_1.getAttrsProperties)(node)); | ||
styledComponents[scName] = { | ||
@@ -109,0 +109,0 @@ name: scName, |
@@ -8,6 +8,6 @@ "use strict"; | ||
) => { | ||
const asProp = jsx_ast_utils_1.getProp(attributes, 'as'); | ||
const asPropValue = jsx_ast_utils_1.getLiteralPropValue(asProp); | ||
const asProp = (0, jsx_ast_utils_1.getProp)(attributes, 'as'); | ||
const asPropValue = (0, jsx_ast_utils_1.getLiteralPropValue)(asProp); | ||
return asPropValue; | ||
}; | ||
exports.getAsPropValue = getAsPropValue; |
@@ -7,7 +7,7 @@ "use strict"; | ||
const isCheckboxOrRadioInput = (node) => { | ||
const tagName = getTagName_1.getTagName(node); | ||
const typeProp = jsx_ast_utils_1.getProp(node.openingElement.attributes, 'type'); | ||
const typePropValue = jsx_ast_utils_1.getLiteralPropValue(typeProp); | ||
const tagName = (0, getTagName_1.getTagName)(node); | ||
const typeProp = (0, jsx_ast_utils_1.getProp)(node.openingElement.attributes, 'type'); | ||
const typePropValue = (0, jsx_ast_utils_1.getLiteralPropValue)(typeProp); | ||
return 'input' === tagName && ['checkbox', 'radio'].includes(typePropValue); | ||
}; | ||
exports.isCheckboxOrRadioInput = isCheckboxOrRadioInput; |
@@ -6,5 +6,5 @@ "use strict"; | ||
const isFormFieldTags = (node) => { | ||
const tagName = getTagName_1.getTagName(node); | ||
const tagName = (0, getTagName_1.getTagName)(node); | ||
return ['input', 'textarea', 'select'].includes(tagName); | ||
}; | ||
exports.isFormFieldTags = isFormFieldTags; |
@@ -7,7 +7,7 @@ "use strict"; | ||
const isHiddenInput = (node) => { | ||
const tagName = getTagName_1.getTagName(node); | ||
const typeProp = jsx_ast_utils_1.getProp(node.openingElement.attributes, 'type'); | ||
const typePropValue = jsx_ast_utils_1.getLiteralPropValue(typeProp); | ||
const tagName = (0, getTagName_1.getTagName)(node); | ||
const typeProp = (0, jsx_ast_utils_1.getProp)(node.openingElement.attributes, 'type'); | ||
const typePropValue = (0, jsx_ast_utils_1.getLiteralPropValue)(typeProp); | ||
return 'input' === tagName && 'hidden' === typePropValue; | ||
}; | ||
exports.isHiddenInput = isHiddenInput; |
@@ -23,3 +23,3 @@ "use strict"; | ||
const allAttrs = originalNodeAttr.concat(attrs.map(propertyToJSXAttribute_1.propertyToJSXAttribute)); | ||
const asPropValue = getAsPropValue_1.getAsPropValue(allAttrs); | ||
const asPropValue = (0, getAsPropValue_1.getAsPropValue)(allAttrs); | ||
node.openingElement.attributes = allAttrs; | ||
@@ -26,0 +26,0 @@ node.openingElement.name.name = asPropValue || tag; |
@@ -16,4 +16,4 @@ "use strict"; | ||
const jsxElements = []; | ||
return Object.assign(Object.assign({}, collectStyledComponentData_1.collectStyledComponentData(collectedStyledComponents)), { JSXElement: (node) => jsxElements.push(node), 'Program:exit': () => { | ||
const parser = jsxElementsParser_1.jsxElementsParser(context, rule, collectedStyledComponents); | ||
return Object.assign(Object.assign({}, (0, collectStyledComponentData_1.collectStyledComponentData)(collectedStyledComponents)), { JSXElement: (node) => jsxElements.push(node), 'Program:exit': () => { | ||
const parser = (0, jsxElementsParser_1.jsxElementsParser)(context, rule, collectedStyledComponents); | ||
jsxElements.forEach((jsxElement) => parser(jsxElement)); | ||
@@ -20,0 +20,0 @@ } }); |
@@ -59,5 +59,5 @@ "use strict"; | ||
var _a; | ||
if (!exports.isStyledTagsWithAttrs(node) && | ||
!exports.isCreateStyledComponentWithAttrs(node) && | ||
!exports.getStyledComponentName(node)) { | ||
if (!(0, exports.isStyledTagsWithAttrs)(node) && | ||
!(0, exports.isCreateStyledComponentWithAttrs)(node) && | ||
!(0, exports.getStyledComponentName)(node)) { | ||
return null; | ||
@@ -64,0 +64,0 @@ } |
{ | ||
"name": "eslint-plugin-react-form-fields", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "React Form Fields specific linting rules for ESLint", | ||
@@ -39,26 +39,27 @@ "engines": { | ||
"@typescript-eslint/experimental-utils": "^4.30.0", | ||
"jsx-ast-utils": "^3.2.0" | ||
"jsx-ast-utils": "^3.2.1" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^13.1.0", | ||
"@commitlint/config-conventional": "^13.1.0", | ||
"@commitlint/prompt-cli": "^13.1.0", | ||
"@commitlint/cli": "^16.0.3", | ||
"@commitlint/config-conventional": "^16.0.0", | ||
"@commitlint/prompt-cli": "^16.0.0", | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/git": "^9.0.1", | ||
"@types/eslint": "^7.28.0", | ||
"@types/jest": "^27.0.1", | ||
"@typescript-eslint/eslint-plugin": "^4.31.0", | ||
"@typescript-eslint/parser": "^4.29.0", | ||
"@types/eslint": "^8.4.0", | ||
"@types/jest": "^27.4.0", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"@typescript-eslint/parser": "^4.33.0", | ||
"all-contributors-cli": "^6.20.0", | ||
"camelcase": "^6.3.0", | ||
"eslint": "^7.32.0", | ||
"husky": "^7.0.1", | ||
"husky": "^7.0.4", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^11.1.2", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.3.2", | ||
"prettier": "^2.5.1", | ||
"rimraf": "^3.0.2", | ||
"semantic-release": "^17.4.5", | ||
"semantic-release": "^17.4.7", | ||
"ts-jest": "^26.5.6", | ||
"ts-node": "^10.2.0", | ||
"typescript": "^4.3.5" | ||
"ts-node": "^10.4.0", | ||
"typescript": "^4.5.4" | ||
}, | ||
@@ -65,0 +66,0 @@ "lint-staged": { |
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
37460
533
22
Updatedjsx-ast-utils@^3.2.1