eslint-plugin-ft-flow
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -36,4 +36,4 @@ # Contributing | ||
2. Update [./.README/README.md](/.README/README.md) to include the new rule. | ||
3. Run `npm run create-readme` to generate the new `README.md` (you must be on `master` branch for this command to work) | ||
3. Run `yarn create-readme` to generate the new `README.md` (you must be on `master` branch for this command to work) | ||
Note: Sections "The following patterns are considered problems:" and "The following patterns are not considered problems:" are **generated automatically** using the test cases. |
@@ -23,2 +23,5 @@ "use strict"; | ||
type: 'boolean' | ||
}, | ||
useExperimentalTypeScriptSyntax: { | ||
type: 'boolean' | ||
} | ||
@@ -30,2 +33,3 @@ }, | ||
var reReadOnly = /^\$(ReadOnly|FlowFixMe)$/; | ||
var reReadOnlyTypeScript = /^(Readonly|$FlowFixMe)$/; | ||
@@ -84,4 +88,9 @@ var isReactComponent = function isReactComponent(node) { | ||
var isReadOnlyName = function isReadOnlyName(name, _ref2) { | ||
var useExperimentalTypeScriptSyntax = _ref2.useExperimentalTypeScriptSyntax; | ||
return useExperimentalTypeScriptSyntax ? reReadOnlyTypeScript.test(name) : reReadOnly.test(name); | ||
}; | ||
var isReadOnlyType = function isReadOnlyType(node, options) { | ||
return node.right.id && reReadOnly.test(node.right.id.name) || isReadOnlyObjectType(node.right, options) || isReadOnlyObjectUnionType(node.right, options); | ||
return node.right.id && isReadOnlyName(node.right.id.name, options) || isReadOnlyObjectType(node.right, options) || isReadOnlyObjectUnionType(node.right, options); | ||
}; | ||
@@ -92,2 +101,4 @@ | ||
var useExperimentalTypeScriptSyntax = _lodash["default"].get(context, ['options', 0, 'useExperimentalTypeScriptSyntax'], false); | ||
var options = { | ||
@@ -102,3 +113,3 @@ useImplicitExactTypes: useImplicitExactTypes | ||
var id = node.superTypeParameters && node.superTypeParameters.params[0].id; | ||
return id && !reReadOnly.test(id.name) && !readOnlyTypes.includes(id.name) && foundTypes.includes(id.name); | ||
return id && !isReadOnlyName(id.name, options) && !readOnlyTypes.includes(id.name) && foundTypes.includes(id.name); | ||
}; | ||
@@ -137,2 +148,3 @@ | ||
var typeName = useExperimentalTypeScriptSyntax ? 'Readonly' : '$ReadOnly'; | ||
return { | ||
@@ -143,3 +155,3 @@ // class components | ||
context.report({ | ||
message: "".concat(node.superTypeParameters.params[0].id.name, " must be $ReadOnly"), | ||
message: "".concat(node.superTypeParameters.params[0].id.name, " must be ").concat(typeName), | ||
node: node | ||
@@ -149,3 +161,3 @@ }); | ||
context.report({ | ||
message: "".concat(node.id.name, " class props must be $ReadOnly"), | ||
message: "".concat(node.id.name, " class props must be ").concat(typeName), | ||
node: node | ||
@@ -173,3 +185,3 @@ }); | ||
if (identifier && foundTypes.includes(identifier.name) && !readOnlyTypes.includes(identifier.name) && !reReadOnly.test(identifier.name)) { | ||
if (identifier && foundTypes.includes(identifier.name) && !readOnlyTypes.includes(identifier.name) && !isReadOnlyName(identifier.name, options)) { | ||
if (reportedFunctionalComponents.includes(identifier)) { | ||
@@ -180,3 +192,3 @@ return; | ||
context.report({ | ||
message: "".concat(identifier.name, " must be $ReadOnly"), | ||
message: "".concat(identifier.name, " must be ").concat(typeName), | ||
node: identifier | ||
@@ -190,3 +202,3 @@ }); | ||
context.report({ | ||
message: "".concat(currentNode.id.name, " component props must be $ReadOnly"), | ||
message: "".concat(currentNode.id.name, " component props must be ").concat(typeName), | ||
node: node | ||
@@ -193,0 +205,0 @@ }); |
{ | ||
"name": "eslint-plugin-ft-flow", | ||
"description": "Flowtype linting rules for ESLint by flow-typed", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
509981
4794
7279