Code Monkey home page Code Monkey logo

mouette's Introduction

Mouette

Mouette is a linter for your MongoDB.

Try it

yarn global add mouette
mouette lint -s summary mongodb://...
mouette lint mongodb://...

To learn more about what mouette can do, run mouette --help

Rules

  • 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.

Features

  • 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

Develop

git clone https://github.com/jsoendermann/mouette/
cd mouette
yarn
npm run watch
node dist/bin/mouette.js lint <your mongodb://...>

Add a new rule

  1. Copy src/rules/_RULE_TEMPLATE.ts to a new file in src/rules/.
  2. Follow the instructions in that file to implement your rule.
  3. Add default options for your new rule to defaultConfig.toml.
  4. Write tests and add them to __tests__/rules.test.ts.
  5. Send me a pull request and share your new rule with the world.

mouette's People

Contributors

jsoendermann avatar

Stargazers

 avatar Guillaume Ongenae avatar  avatar Nadeem Jabbar Qureshi avatar Clifford Duke avatar Remo H. Jansen avatar  avatar Lyman Lai avatar Ennea8 avatar Jack Kavanagh avatar Walter Wu avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

anpamela

mouette's Issues

Add save-days-in-string-when-possible rule

This is a fuzzy rule that operates on date columns. If the dates are clustered around a certain time of day, it should suggest changing from Date to strings of the form "YYYY-MM-DD"

Add enforce-enums rule

This is a fuzzy rule that should try to figure out if there are abnormal values in a column that looks like an enum

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.