Skip to content

Commit

Permalink
feat!: drop max-len rule from 160 to 90
Browse files Browse the repository at this point in the history
This sets the maximum line length to 90 for lines of source code.
Currently, comments are ignored so those lines are an exception to the
rule.

Semver: major
Ref: LOG-7437
  • Loading branch information
esatterwhite committed Sep 30, 2020
1 parent 97e10f2 commit 5caf579
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}
}],
"linebreak-style": ["error", "unix"],
"max-len": [2, 160, {
"max-len": [2, 90, {
"ignoreComments": true
}],
"no-alert": 2,
Expand Down
21 changes: 17 additions & 4 deletions test/failures.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@ const fs = require('fs')
const {test, threw} = require('tap')
const {CLIEngine} = require('eslint')
const EOL_CODE = path.join(__dirname, 'fixtures', 'no-eol-fixture')
const MAX_LEN_CODE = path.join(__dirname, 'fixtures', 'max-len-fixture')

const readFile = fs.promises.readFile
test('invalid config', async (t) => {
const code = await readFile(EOL_CODE, 'utf8')
const cli = new CLIEngine({
useEslintrc: false
, configFile: 'eslintrc.json'
})

const result = cli.executeOnText(code)
t.equal(result.errorCount, 1, 'new line missing')
t.equal(result.results[0].messages[0].ruleId, 'eol-last', 'missing newline')
t.test('no-eol', async (t) => {
const code = await readFile(EOL_CODE, 'utf8')
const result = cli.executeOnText(code)
t.equal(result.errorCount, 1, 'error count')
t.equal(result.results[0].messages[0].ruleId, 'eol-last', 'missing newline')
})

t.test('max-len', async (t) => {
const code = await readFile(MAX_LEN_CODE, 'utf8')
const result = cli.executeOnText(code)
t.equal(result.errorCount, 1, 'error count')
const messages = result.results[0].messages

t.equal(messages[0].ruleId, 'max-len', 'max length exceeded')
t.match(messages[0].message, /maximum allowed is 90/ig, 'message expected line length')
})
}).catch(threw)
1 change: 1 addition & 0 deletions test/fixture
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

// This is a very very long comment that should probably be on multiple line. But comments are ignored so this will not cause an error when the linter actually runs
const path = require('path')
const fs = require('fs')
const {promisify} = require('util')
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/max-len-fixture
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

const BREAK_MAX_LEN = 'this is a very long string that will excced the maximum line length of 90'

module.exports = {
BREAK_MAX_LEN
}

0 comments on commit 5caf579

Please sign in to comment.