Created
December 16, 2020 22:14
-
-
Save lyleunderwood/9ecc2408a3fb8fc8955934af3c92a477 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unsealedObjectError = () => 'Flow interprets empty objects literals as unsealed objects,' + | |
' see https://git.io/fj64j'; | |
module.exports = { | |
'no-unsealed-objects': { | |
meta: { | |
docs: { | |
description: 'no unsealed objects', | |
category: 'Possible Errors', | |
recommended: false, | |
}, | |
schema: [], | |
fixable: 'code', | |
}, | |
create: (context) => { | |
// ignore fixture data | |
const filename = context.getFilename(); | |
if (filename.match(/fixtures/)) return { ...null }; | |
return { | |
ObjectExpression: (node) => { | |
if (node.properties.length === 0) { | |
context.report({ | |
node, | |
message: unsealedObjectError(), | |
fix: fixer => fixer.replaceText(node, '{ ...null }'), | |
}); | |
} | |
}, | |
}; | |
}, | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment