Skip to content

Commit

Permalink
feat(eslint-config): support strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed Sep 21, 2023
1 parent 20c91cc commit c9b0c89
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-wombats-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@git-validator/eslint-config": patch
---

feat(eslint-config): support strict mode
19 changes: 17 additions & 2 deletions packages/eslint-config/src/ts-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ function getTsRules() {
};
}

function getStrictRules() {
if (process.env["STRICT"] || process.env["ESLINT_STRICT"]) {
return {
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "never" }],
"@typescript-eslint/no-non-null-assertion": "error",
};
}
return {};
}

export default {
files: ["**/*.ts", "**/*.cts", "**/*.mts", "**/*.tsx"],
languageOptions: {
Expand All @@ -104,6 +115,10 @@ export default {

// ban some syntaxes to reduce mistakes
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/consistent-type-assertions": [
"error",
{ assertionStyle: "as", objectLiteralTypeAssertions: "never" },
],
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-duplicate-type-constituents": "error",
Expand All @@ -121,12 +136,12 @@ export default {
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
// "@typescript-eslint/consistent-type-imports": "error",
// "@typescript-eslint/unbound-method": "error",
// "@typescript-eslint/no-non-null-assertion": "error",s

"@git-validator/no-const-enum": "error",
"@git-validator/no-declares-in-ts-file": "error",
"@git-validator/no-export-assignment": "error",

...getStrictRules(),
},
};

0 comments on commit c9b0c89

Please sign in to comment.