JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q36335F
  • License Apache-2.0

find technical errors in Common Forms

Package Exports

  • commonform-lint

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (commonform-lint) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

lint takes a Common Form argument and returns an array of Common Form Annotations.

Broken Cross-References

var message = 'The heading "Indemnity" is referenced, but not used.'

assert.deepEqual(
  lint({ content: [ { reference: 'Indemnity' } ] }),
  [ { message: message,
      level: 'error',
      path: [ 'content', 0 ],
      source: 'commonform-lint',
      url: null } ],
  'returns commonform-annotation noting broken reference')

assert.deepEqual(
  lint({
    content: [
      { reference: 'Indemnity' },
      { reference: 'Indemnity' } ] }),
  [ { message: message,
      level: 'error',
      path: [ 'content', 0 ],
      source: 'commonform-lint',
      url: null },
    { message: message,
      level: 'error',
      path: [ 'content', 1 ],
      source: 'commonform-lint',
      url: null } ],
  'notes multiple broken references')

Defined Terms

Conflicting Definitions

assert.deepEqual(
  lint({
    content: [
      { definition: 'Agreement' },
      { definition: 'Agreement' },
      { definition: 'Consideration' },
      { use: 'Agreement' },
      { use: 'Consideration' } ] }),
  [ { message: 'The term "Agreement" is defined more than once.',
      level: 'error',
      path: [ 'content', 0 ],
      source: 'commonform-lint',
      url: null },
    { message: 'The term "Agreement" is defined more than once.',
      level: 'error',
      path: [ 'content', 1 ],
      source: 'commonform-lint',
      url: null } ],
  'notes multiple definitions of the same term')

Undefined Terms

assert.deepEqual(
  lint({ content: [ { use: 'Agreement' } ] }),
  [ { message: 'The term "Agreement" is used, but not defined.',
      level: 'error',
      path: [ 'content', 0 ],
      source: 'commonform-lint',
      url: null } ],
  'reports the use of an undefined term')

assert.deepEqual(
  lint({ content: [ { use: 'Agreement' }, { use: 'Agreement' } ] }),
  [ { message: 'The term "Agreement" is used, but not defined.',
      level: 'error',
      path: [ 'content', 0 ],
      source: 'commonform-lint',
      url: null },
    { message: 'The term "Agreement" is used, but not defined.',
      level: 'error',
      path: [ 'content', 1 ],
      source: 'commonform-lint',
      url: null } ],
  'notes multiple uses of an undefined term')

Extra Definitions

assert.deepEqual(
  lint({ content: [ { definition: 'Agreement' } ] }),
  [ { message: 'The term "Agreement" is defined, but not used.',
      level: 'warn',
      path: [ 'content', 0 ],
      source: 'commonform-lint',
      url: null } ],
  'notes use of an unused definition')

Structurally Sound Forms

assert.deepEqual(
  lint({
    content: [
      { definition: 'Agreement' },
      { definition: 'Consideration' },
      { use: 'Agreement' },
      { use: 'Consideration' } ] }),
  [ ])

assert.deepEqual(
  lint({
    content: [
      { heading: 'Heading',
        form: { content: [ 'test' ] } },
      { reference: 'Heading' },
      { definition: 'Term' },
      { use: 'Term' } ] }),
  [ ])