diff --git a/.eslintrc.yml b/.eslintrc.yml index bee112d4a..51a35b1a8 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -120,9 +120,6 @@ overrides: prettier-internal-rules/prefer-fast-path-each: error prettier-internal-rules/prefer-indent-if-break: error prettier-internal-rules/prefer-is-non-empty-array: error - - files: src/document/*.js - rules: - prettier-internal-rules/no-doc-builder-concat: off - files: - src/language-*/**/*.js rules: diff --git a/package.json b/package.json index 063213466..7912cc880 100644 --- a/package.json +++ b/package.json @@ -150,7 +150,7 @@ "lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly", "lint:changelog": "node ./scripts/lint-changelog.js", "lint:prettier": "prettier . \"!test*\" --check", - "lint:dist": "eslint --no-eslintrc --no-ignore --env=es6,browser --parser-options=ecmaVersion:2018 \"dist/!(bin-prettier|index|third-party).js\"", + "lint:dist": "eslint --no-eslintrc --no-ignore --no-inline-config --env=es6,browser --parser-options=ecmaVersion:2018 \"dist/!(bin-prettier|index|third-party).js\"", "lint:spellcheck": "cspell \"**/*\" \".github/**/*\"", "lint:deps": "node ./scripts/check-deps.js", "fix": "run-s fix:eslint fix:prettier", diff --git a/src/document/doc-builders.js b/src/document/doc-builders.js index 2a26cf0e4..9747dcd18 100644 --- a/src/document/doc-builders.js +++ b/src/document/doc-builders.js @@ -211,7 +211,9 @@ const literallineWithoutBreakParent = { const line = { type: "line" }; const softline = { type: "line", soft: true }; +// eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat const hardline = concat([hardlineWithoutBreakParent, breakParent]); +// eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat const literalline = concat([literallineWithoutBreakParent, breakParent]); const cursor = { type: "cursor", placeholder: Symbol("cursor") }; @@ -232,6 +234,7 @@ function join(sep, arr) { res.push(arr[i]); } + // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat return concat(res); } diff --git a/src/document/doc-printer.js b/src/document/doc-printer.js index cdcecaa93..64509a440 100644 --- a/src/document/doc-printer.js +++ b/src/document/doc-printer.js @@ -2,7 +2,7 @@ const { getStringWidth } = require("../common/util"); const { convertEndOfLineToChars } = require("../common/end-of-line"); -const { concat, fill, cursor, indent } = require("./doc-builders"); +const { fill, cursor, indent } = require("./doc-builders"); const { isConcat, getDocParts } = require("./doc-utils"); /** @type {Record} */ @@ -452,7 +452,7 @@ function printDocToString(doc, options) { const firstAndSecondContentFlatCmd = [ ind, MODE_FLAT, - concat([content, whitespace, secondContent]), + [content, whitespace, secondContent], ]; const firstAndSecondContentFits = fits( firstAndSecondContentFlatCmd, diff --git a/src/document/doc-utils.js b/src/document/doc-utils.js index aac57de7f..29333a4b2 100644 --- a/src/document/doc-utils.js +++ b/src/document/doc-utils.js @@ -1,6 +1,6 @@ "use strict"; -const { literalline, concat } = require("./doc-builders"); +const { literalline } = require("./doc-builders"); const isConcat = (doc) => Array.isArray(doc) || (doc && doc.type === "concat"); const getDocParts = (doc) => { @@ -371,11 +371,7 @@ function normalizeDoc(doc) { function replaceNewlinesWithLiterallines(doc) { return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" && currentDoc.includes("\n") - ? concat( - currentDoc - .split(/(\n)/g) - .map((v, i) => (i % 2 === 0 ? v : literalline)) - ) + ? currentDoc.split(/(\n)/g).map((v, i) => (i % 2 === 0 ? v : literalline)) : currentDoc ); }