Mouette is a linter for your MongoDB.
yarn global add mouette
mouette lint -s summary mongodb://...
mouette lint mongodb://...
To learn more about what mouette can do, run mouette --help
- Collection names camel/snake case: Make sure all collection names in the database have the right case.
- case: The case your collection names should be in.
- Collection names singular/plural: Make sure all collections in the database have names that are either singular or plural.
- number: The grammatical number that collection names should be checked for.
- Key names singular/plural: Make sure all keys in the database have the right case.
- case: The case your keys should be in.
- Keys that end in At should refer to dates: Make sure columns with keys that end in ...At contain nothing but dates.
- allow-stringified-days: Whether to allow dates that are saved as strings.
- stringified-days-regex: The regexp used to determine whether a string contains a date.
- Max key count: Enforces a maximum number of keys per collection.
- maximum-excluding-_id: The maximum number of keys allowed.
- No bad key names: Make sure no common bad key names are used.
- names-considered-bad: Key names that should be avoided.
- No dates saved as string: Makes sure dates don't get saved as strings.
- No leading underscores in key names: Make sure no key name except _id starts with an underscore.
- No mixed types: Makes sure columns contain values of no more than one type.
- No null: Make sure columns do not contain null values.
- No numbers saved as string: Makes sure numbers don't get saved as strings.
- strict-number-check: When this is set to true, strings like '015', '0xF' or '0b1111 are not considered to be numbers.
- No undefined: Make sure columns do not contain undefined values.
- Question keys should refer to booleans: Make sure columns with keys that start with verbs like "is" or "has" contain nothing but booleans.
- boolean-key-prefixes: Which prefixes should indicate booleans.
- Completely schemaless, mouette needs no information about your db to run
- Suggests fixes where possible
- Prints queries ready to be pasted into the MongoDB shell that print all the documents that need fixing
- Includes a diffing function that can be used to find all rule violations that were added since your last lint
- Can be run as a binary or included as a library
git clone https://github.com/jsoendermann/mouette/
cd mouette
yarn
npm run watch
node dist/bin/mouette.js lint <your mongodb://...>
- Copy
src/rules/_RULE_TEMPLATE.ts
to a new file insrc/rules/
. - Follow the instructions in that file to implement your rule.
- Add default options for your new rule to
defaultConfig.toml
. - Write tests and add them to
__tests__/rules.test.ts
. - Send me a pull request and share your new rule with the world.