1.0.3 • Published 5 years ago

commonform-critique v1.0.3

Weekly downloads
6
License
BlueOak-1.0.0
Repository
github
Last release
5 years ago

commonform-critique

suggest improvements to Common Forms

var critique = require('commonform-critique')
var assert = require('assert')

assert.deepStrictEqual(
  critique({ content: ['to wit'] })[0],
  [
    {
      message: 'The phrase "to wit" is archaic.',
      level: 'info',
      path: ['content', 0],
      source: 'commonform-archaic',
      url: null
    }
  ][0]
)

assert.deepStrictEqual(
  critique({ content: ['to witness'] }),
  []
)

assert.deepStrictEqual(
  critique({ content: ['in order to'] }),
  [
    {
      message: 'Replace "in order to" with "to".',
      level: 'info',
      path: ['content', 0],
      source: 'commonform-critique',
      url: null
    }
  ]
)

assert.deepStrictEqual(
  critique({ content: ['this /that'] }),
  [
    {
      message: 'Remove the space before "/".',
      level: 'info',
      path: ['content', 0],
      source: 'commonform-critique',
      url: null
    }
  ]
)

assert.deepStrictEqual(
  critique({ content: ['this/ that'] }),
  [
    {
      message: 'Remove the space after "/".',
      level: 'info',
      path: ['content', 0],
      source: 'commonform-critique',
      url: null
    }
  ]
)

assert.deepStrictEqual(
  critique({ content: [{ form: { content: ['this / that'] } }] }),
  [
    {
      message: 'Remove the space before "/".',
      level: 'info',
      path: ['content', 0, 'form', 'content', 0],
      source: 'commonform-critique',
      url: null
    },
    {
      message: 'Remove the space after "/".',
      level: 'info',
      path: ['content', 0, 'form', 'content', 0],
      source: 'commonform-critique',
      url: null
    }
  ]
)

assert.deepStrictEqual(
  critique({ content: ['Give me two (2) of those and four (4) of the other one.'] }),
  [
    {
      message: '"two (2)" repeats a written number and numeral, which is redundant and error-prone',
      level: 'info',
      path: ['content', 0],
      source: 'doubleplus-numbers',
      url: null
    },
    {
      message: '"four (4)" repeats a written number and numeral, which is redundant and error-prone',
      level: 'info',
      path: ['content', 0],
      source: 'doubleplus-numbers',
      url: null
    }
  ]
)

assert.deepStrictEqual(
  critique({ content: ['Do not use any silly words whatsoever.'] }),
  [
    {
      message: (
        'The phrase "whatsoever" should as a general matter be absent from your contracts.' +
        ' See MSCD appendix 2, pages 454-455.'
      ),
      level: 'info',
      path: ['content', 0],
      source: 'commonform-mscd',
      url: null
    }
  ]
)
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.8.1

9 years ago

0.8.0

9 years ago

0.7.0

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.8

9 years ago

0.5.7

9 years ago

0.5.6

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago