eslint-plugin-ft-flow
Version:
Flowtype linting rules for ESLint by flow-typed
49 lines (42 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var schema = [{
"enum": ['always', 'never'],
type: 'string'
}];
var create = function create(context) {
var always = (context.options[0] || 'always') === 'always';
return {
ObjectTypeAnnotation: function ObjectTypeAnnotation(node) {
var _node$parent, _node$parent2;
var inexact = node.inexact,
exact = node.exact; // Only type objects can specify exactness
if ((node === null || node === void 0 ? void 0 : (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.type) === 'InterfaceDeclaration' || (node === null || node === void 0 ? void 0 : (_node$parent2 = node.parent) === null || _node$parent2 === void 0 ? void 0 : _node$parent2.type) === 'DeclareClass') {
return;
}
if (always && !inexact && !exact) {
context.report({
message: 'Type must be explicit inexact.',
node: node
});
}
if (!always && inexact) {
context.report({
message: 'Type must not be explicit inexact.',
node: node
});
}
}
};
};
var _default = {
create: create,
meta: {
schema: schema
}
};
exports["default"] = _default;
module.exports = exports.default;