eslint-plugin-ft-flow
Version:
Flowtype linting rules for ESLint by flow-typed
34 lines (30 loc) • 692 B
Flow
const schema = [
{
enum: ['always', 'never'],
type: 'string',
},
];
const create = (context) => ({
ObjectTypeAnnotation(node) {
const { properties } = node;
for (const property of properties) {
const { type } = property;
if (type === 'ObjectTypeSpreadProperty') {
const { argument: { type: argumentType, id: argumentId } } = property;
if (
argumentType !== 'GenericTypeAnnotation' || argumentId.name !== '$Exact') {
context.report({
message: 'Use $Exact to make type spreading safe.',
node,
});
}
}
}
},
});
export default {
create,
meta: {
schema,
},
};