Skip to content

Commit

Permalink
Remove eslint rules covered by dprint
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Jun 28, 2023
1 parent 266502c commit b81a0b3
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 790 deletions.
36 changes: 2 additions & 34 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-array-constructor": "error",

"brace-style": "off",
"@typescript-eslint/brace-style": ["error", "stroustrup", { "allowSingleLine": true }],

"@typescript-eslint/naming-convention": [
"error",
{ "selector": "typeLike", "format": ["PascalCase"], "filter": { "regex": "^(__String|[A-Za-z]+_[A-Za-z]+)$", "match": false } },
Expand All @@ -55,58 +52,33 @@
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/consistent-type-assertions": ["error", { "assertionStyle": "as" }],

"max-statements-per-line": ["error", { "max": 1 }],

"no-duplicate-imports": "off",
"@typescript-eslint/no-duplicate-imports": "error",

"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-this-alias": "error",

"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": ["error", { "allowTernary": true }],

"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/prefer-as-const": "error",

"quotes": "off",
"@typescript-eslint/quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],

"semi": "off",
"@typescript-eslint/semi": "error",
"@typescript-eslint/no-extra-semi": "error",

"space-before-function-paren": "off",
"@typescript-eslint/space-before-function-paren": ["error", {
"asyncArrow": "always",
"anonymous": "always",
"named": "never"
}],

"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",

"@typescript-eslint/no-extra-non-null-assertion": "error",

// TODO(jakebailey): remove this and other formatting related rules once dprint is enabled.
"@typescript-eslint/comma-dangle": ["error", "always-multiline"],

// scripts/eslint/rules
"local/object-literal-surrounding-space": "error",
"local/no-type-assertion-whitespace": "error",
"local/type-operator-spacing": "error",
// TODO(jakebailey): no-double-space covers formatting of code that dprint handles, but also reads the text in comments.
"local/no-double-space": "error",
"local/only-arrow-functions": ["error", {
"allowNamedFunctions": true,
"allowDeclarations": true
}],
"local/no-double-space": "error",
"local/argument-trivia": "error",
"local/no-in-operator": "error",
"local/simple-indent": "error",
"local/debug-assert": "error",
"local/no-keywords": "error",
"local/jsdoc-format": "error",
Expand All @@ -119,11 +91,9 @@

// eslint
"constructor-super": "error",
"curly": ["error", "multi-line"],
"dot-notation": "error",
"eqeqeq": "error",
"linebreak-style": ["error", "windows"],
"new-parens": "error",
"no-caller": "error",
"no-duplicate-case": "error",
"no-empty": "error",
Expand All @@ -137,7 +107,6 @@
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-unsafe-finally": "error",
"no-unused-labels": "error",
Expand All @@ -146,7 +115,6 @@
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": ["error", "consistent-as-needed"],
"space-in-parens": "error",
"unicode-bom": ["error", "never"],
"use-isnan": "error",
"no-prototype-builtins": "error",
Expand Down
61 changes: 0 additions & 61 deletions scripts/eslint/rules/jsdoc-format.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = createRule({
internalCommentNotLastError: `@internal should only appear in final JSDoc comment for declaration.`,
multipleJSDocError: `Declaration has multiple JSDoc comments.`,
internalCommentOnParameterProperty: `@internal cannot appear on a JSDoc comment; use a declared property and an assignment in the constructor instead.`,
misalignedJSDocComment: `This JSDoc comment is misaligned.`,
},
schema: [],
type: "problem",
Expand Down Expand Up @@ -93,67 +92,7 @@ module.exports = createRule({
}
};

/** @type {(node: TSESTree.Node) => void} */
const checkProgram = () => {
const comments = sourceCode.getAllComments();

for (const c of comments) {
if (c.type !== "Block") {
continue;
}

const rawComment = sourceCode.getText(c);
if (!isJSDocText(rawComment)) {
continue;
}

const expected = c.loc.start.column + 2;
const split = rawComment.split(/\r?\n/g);
for (let i = 1; i < split.length; i++) {
const line = split[i];
const match = /^ *\*/.exec(line);
if (!match) {
continue;
}

const actual = match[0].length;
const diff = actual - expected;
if (diff !== 0) {
const line = c.loc.start.line + i;
context.report({
messageId: "misalignedJSDocComment",
node: c,
loc: {
start: {
line,
column: 0,
},
end: {
line,
column: actual - 1,
},
},
fix: fixer => {
if (diff > 0) {
// Too many
const start = sourceCode.getIndexFromLoc({ line, column: expected - 1 });
return fixer.removeRange([start, start + diff]);
}
else {
// Too few
const start = sourceCode.getIndexFromLoc({ line, column: 0 });
return fixer.insertTextAfterRange([start, start], " ".repeat(-diff));
}
},
});
break;
}
}
}
};

return {
Program: checkProgram,
ClassDeclaration: checkDeclaration,
FunctionDeclaration: checkDeclaration,
TSEnumDeclaration: checkDeclaration,
Expand Down
43 changes: 0 additions & 43 deletions scripts/eslint/rules/no-type-assertion-whitespace.cjs

This file was deleted.

72 changes: 0 additions & 72 deletions scripts/eslint/rules/object-literal-surrounding-space.cjs

This file was deleted.

69 changes: 0 additions & 69 deletions scripts/eslint/rules/simple-indent.cjs

This file was deleted.

Loading

0 comments on commit b81a0b3

Please sign in to comment.