-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
115 lines (111 loc) · 6.26 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
plugins: ["@typescript-eslint"],
extends: [
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"plugin:@stencil-community/recommended", // Enables @stencil-community/eslint-plugin.
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
ecmaVersion: 2022, // Allows for the parsing of modern ECMAScript features
project: "./tsconfig.json",
sourceType: "module" // Allows for the use of imports
},
ignorePatterns: [
"src/deprecated-components/*",
"node_modules/*",
"www/*",
"dist/*"
],
rules: {
// - - - - - - - - - - - -
// ESLint
// - - - - - - - - - - - -
camelcase: "warn", // Enforce camelcase naming convention
curly: "error", // Enforce consistent brace style for all control statements
eqeqeq: ["warn", "always", { null: "ignore" }], // Require the use of === and !== "ignore" -------> Do not apply this rule to null
"logical-assignment-operators": [
"warn",
"always",
{ enforceForIfStatements: true }
], // This rule checks for expressions that can be shortened using logical assignment operator
"dot-notation": "warn", // This rule is aimed at maintaining code consistency and improving code readability by encouraging use of the dot notation style whenever possible. As such, it will warn when it encounters an unnecessary use of square-bracket notation.
"max-depth": ["warn", 3], // Enforce a maximum depth that blocks can be nested. Many developers consider code difficult to read if blocks are nested beyond a certain depth
"no-alert": "error", // Disallow the use of alert, confirm, and prompt
"no-console": "warn", // Warning when using console.log, console.warn or console.error
"no-else-return": ["warn", { allowElseIf: false }], // Disallow else blocks after return statements in if statements
"no-extra-boolean-cast": "error", // Disallow unnecessary boolean casts
"no-debugger": "error", // Error when using debugger;
"no-duplicate-case": "error", // This rule disallows duplicate test expressions in case clauses of switch statements
"no-empty": "error", // Disallow empty block statements
"no-lonely-if": "error", // Disallow if statements as the only statement in else blocks
"no-multi-assign": "error", // Disallow use of chained assignment expressions
"no-nested-ternary": "error", // Errors when using nested ternary expressions
"no-sequences": "error", // Disallow comma operators
"no-undef": "off", // Allows defining undefined variables
"no-unneeded-ternary": "error", // Disallow ternary operators when simpler alternatives exist
"no-useless-return": "error", // Disallow redundant return statements
"spaced-comment": ["error", "always", { exceptions: ["-", "+", "/"] }], // Enforce consistent spacing after the // or /* in a comment
// - - - - - - - - - - - -
// TypeScript ESLint
// - - - - - - - - - - - -
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-use-before-define": ["error", { functions: false }],
"@typescript-eslint/no-unused-vars": [
"error",
{ varsIgnorePattern: "^(h)$" }
],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
// - - - - - - - - - - - -
// Prettier
// - - - - - - - - - - - -
"prettier/prettier": [
"error",
{
endOfLine: "auto"
}
],
// - - - - - - - - - - - -
// StencilJS
// - - - - - - - - - - - -
"@stencil-community/async-methods": "error", // This rule catches Stencil public methods that are not async
"@stencil-community/decorators-context": "error", // This rule catches Stencil decorators in bad locations
"@stencil-community/decorators-style": [
"warn",
{
// prop: "inline", // And multiline
state: "inline",
element: "inline",
method: "multiline",
watch: "multiline",
listen: "multiline"
}
],
"@stencil-community/ban-exported-const-enums": "warn", // Exported const enums are not allowed
"@stencil-community/element-type": "error", // This rule catches Stencil Element decorator have the correct type
"@stencil-community/methods-must-be-public": "error", // This rule catches Stencil Methods marked as private or protected
"@stencil-community/no-unused-watch": "error", // This rule catches Stencil Watchs with non existing Props or States
"@stencil-community/own-methods-must-be-private": "warn", // This rule catches own class methods marked as public
"@stencil-community/own-props-must-be-private": "warn", // This rule catches own class properties marked as public
"@stencil-community/prefer-vdom-listener": "warn", // This rule catches Stencil Listen with vdom events
"@stencil-community/props-must-be-public": "error", // This rule catches Stencil Props marked as private or protected
"@stencil-community/props-must-be-readonly": "error", // This rule catches Stencil Props marked as non readonly, excluding mutable ones
"@stencil-community/required-jsdoc": "error", // This rule catches Stencil Props, Methods and Events to define jsdoc
"@stencil-community/required-prefix": ["error", ["ch-"]], // Ensures that a Component's tag use the "ch-" prefix.
"@stencil-community/reserved-member-names": "warn", // Ensures that any of reserved global HTML attribute names are used as @Prop or @Method
"@stencil-community/single-export": "error", // This rule catches modules that expose more than just the Stencil Component itself
"@stencil-community/strict-boolean-conditions": "off",
// WA to fix false positive errors
"@stencil-community/strict-mutable": "warn" // This rule catches Stencil Prop marked as mutable but not changing value in code
}
// overrides: [
// {
// files: ["**/*.tsx"],
// rules: {
// "local/jsx-uses-my-pragma": "error", // These are needed to avoid getting a not used error with imports used in JSX
// "local/jsx-uses-vars": "error"
// }
// }
// ]
};