Skip to content

Commit

Permalink
style(prettier): enforce default style in new TS files (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomaash authored Aug 27, 2019
1 parent b06e9da commit bf4095e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 13 deletions.
87 changes: 85 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,88 @@ module.exports = {
'valid-typeof': 'off',
},
},
],
}
{
files: [
"lib/index-bundle.ts",
"lib/index.ts",
"lib/network/gephiParser.ts",
"test/NodesHandler.test.ts",
"test/dot-parser/dot-parser.test.ts",
"test/edges/bezier-edge-dynamic.test.ts",
"test/edges/bezier-edge-static.test.ts",
"test/edges/cubic-bezier-edge.test.ts",
"test/edges/edge-base.test.ts",
"test/edges/end-points.test.ts",
"test/edges/helpers.ts",
"test/edges/straight-edge.test.ts",
"test/gephi-parser.test.ts",
"test/helpers/index.ts"
],
rules: {
"prettier/prettier": [
"error",
{
endOfLine: "lf",
parser: "typescript",
printWidth: 80,
quoteProps: "consistent",
semi: false,
singleQuote: true,
tabWidth: 2,
trailingComma: "es5",
useTabs: false
}
],

// @TODO: Seems to mostly work just fine but I'm not 100 % sure.
// @TODO: Deprecated, anything like this for tsdoc?
"valid-jsdoc": [
"error",
{
prefer: {
arg: "param",
argument: "param",
return: "returns"
},
requireParamDescription: true,
requireParamType: false,
requireReturn: false, // Requires return for void functions.
requireReturnDescription: true,
requireReturnType: false
}
],

// Class related.
"@typescript-eslint/member-naming": [
"error",
{ private: "^_", protected: "^_", public: "^[^_]" }
],
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/prefer-readonly": "error",

// Other.
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-regexp-exec": "error",
// @TODO: Seems like a good thing, not yet on npm though.
// "@typescript-eslint/require-await": "error",

// These are hoisted, I have no idea why it reports them by default.
"@typescript-eslint/no-use-before-define": [
"error",
{ functions: false, classes: false, typedefs: false }
],
// False positives for overloading, also tsc compiles with errors anyway.
"no-dupe-class-members": "off",
// Blocks typesafe exhaustive switch (switch (x) { … default: const never: never = x }).
"no-case-declarations": "off",
// Reports used types.
"no-unused-vars": "off",
// Reports typeof bigint as an error, tsc validates this anyway so no problem turning this off.
"valid-typeof": "off"
}
},
]
};
12 changes: 1 addition & 11 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
{
"endOfLine": "lf",
"parser": "typescript",
"printWidth": 80,
"quoteProps": "consistent",
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false
}
{}

0 comments on commit bf4095e

Please sign in to comment.