Skip to main content

description-format

Enabling this rule will result in an error being generated if description doesn't meet the configured options. Two options exist:

  1. requireCapitalFirstLetter - Throws an error if the first character in the description isn't capitalized.
  2. requireEndingPeriod - Throws an error if the description doesn't end with a period.
  3. forbidEndingPeriod - Throws an error if the description ends with a period.

Example .npmpackagejsonlintrc configuration

{
"rules": {
"description-format": ["error", {
"requireCapitalFirstLetter": true,
"requireEndingPeriod": true
}]
}
}

Rule Details

Incorrect example(s)

{
"description": "i'm a valid description."
}
{
"description": "I'm a valid description"
}

Correct example(s)

{
"description": "I'm a valid description."
}

Example .npmpackagejsonlintrc configuration with only requireCapitalFirstLetter

{
"rules": {
"description-format": ["error", {
"requireCapitalFirstLetter": true
}]
}
}
{
"rules": {
"description-format": ["error", {
"requireCapitalFirstLetter": true,
"requireEndingPeriod": false
}]
}
}

Rule Details

Incorrect example(s)

{
"description": "i'm a valid description."
}

Correct example(s)

{
"description": "I'm a valid description."
}
{
"description": "I'm a valid description"
}

Example .npmpackagejsonlintrc configuration with only requireEndingPeriod

{
"rules": {
"description-format": ["error", {
"requireEndingPeriod": true
}]
}
}
{
"rules": {
"description-format": ["error", {
"requireCapitalFirstLetter": false,
"requireEndingPeriod": true
}]
}
}

Rule Details

Incorrect example(s)

{
"description": "I'm a valid description"
}

Correct example(s)

{
"description": "I'm a valid description."
}
{
"description": "i'm a valid description."
}

Example .npmpackagejsonlintrc configuration with only forbidEndingPeriod

{
"rules": {
"description-format": ["error", {
"forbidEndingPeriod": true
}]
}
}
{
"rules": {
"description-format": ["error", {
"requireCapitalFirstLetter": false,
"forbidEndingPeriod": true
}]
}
}

Rule Details

Incorrect example(s)

{
"description": "I'm a valid description."
}

Correct example(s)

{
"description": "I'm a valid description"
}
{
"description": "i'm a valid description"
}

Configuration Exception

An exception will be thrown if requireEndingPeriod and forbidEndingPeriod are set to true.

History

  • Added forbidEndingPeriod option in version 4.6.0
  • Introduced in version 3.3.0