Skip to content

Commit

Permalink
feat: Update rules according to PR 427 (#436)
Browse files Browse the repository at this point in the history
* feat: Update rules according to PR 427

---------

Co-authored-by: Thatchapon Unprasert <[email protected]>
  • Loading branch information
PoomSmart and Thatchapon Unprasert authored Nov 7, 2024
1 parent 4d6f7da commit 2f7ddbb
Show file tree
Hide file tree
Showing 7 changed files with 734 additions and 101 deletions.
9 changes: 8 additions & 1 deletion configs/@typescript-eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ module.exports = {
"extendDefaults": true,
},
],
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase", "PascalCase", "UPPER_CASE"],
"leadingUnderscore": "allow"
}
],
"@typescript-eslint/consistent-type-assertions": ["error"],
"@typescript-eslint/no-array-constructor": ["error"],
"@typescript-eslint/no-empty-function": ['error', { 'allow': ['arrowFunctions'] }],
Expand Down
21 changes: 3 additions & 18 deletions configs/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ module.exports = {
"max-len": [
"error",
{
code: 120,
code: 200,
tabWidth: 2,
ignoreTemplateLiterals: true,
ignoreStrings: true,
ignoreComments: true
}
],
"comma-dangle": ["error", "never"],
"comma-dangle": ["error", "always-multiline"], // not having a trailing comma results in unnecessary git changes
"implicit-arrow-linebreak": ["off", "beside"],
camelcase: [
"off",
Expand Down Expand Up @@ -193,22 +193,7 @@ module.exports = {
allowUnboundThis: true
}
],
"prefer-destructuring": [
"error",
{
VariableDeclarator: {
array: false,
object: true
},
AssignmentExpression: {
array: true,
object: false
}
},
{
enforceForRenamedProperties: false
}
],
"prefer-destructuring": ["off"], // adds unnecessary lines and removes context from code
"prefer-numeric-literals": ["error"],
"prefer-reflect": ["off"],
"prefer-template": ["error"],
Expand Down
4 changes: 2 additions & 2 deletions configs/import/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
caseSensitive: true
}
],
"import/named": ["error"],
"import/named": ["off"], // not required for TS
"import/default": ["off"],
"import/namespace": ["off"],
"import/export": ["error"],
Expand Down Expand Up @@ -66,7 +66,7 @@ module.exports = {
}
],
"import/newline-after-import": ["error"],
"import/prefer-default-export": ["error"],
"import/prefer-default-export": ["off"], // // adds unnecessary code change requirements when updating a 1 export module to multiple export and vice versa
"import/no-restricted-paths": ["off"],
"import/max-dependencies": [
"off",
Expand Down
9 changes: 2 additions & 7 deletions configs/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,7 @@ module.exports = {
],
"react/jsx-space-before-closing": ["off", "always"],
"react/no-array-index-key": ["error"],
"react/require-default-props": [
"error",
{
forbidDefaultForRequired: true
}
],
"react/require-default-props": ["off"], // not relevant to modern React with TS functional components
"react/forbid-foreign-prop-types": [
"off",
{
Expand Down Expand Up @@ -297,7 +292,7 @@ module.exports = {
children: "never"
}
],
"react/destructuring-assignment": ["error", "always"],
"react/destructuring-assignment": ["off"], // adds unnecessary lines and removes context from code
"react/no-access-state-in-setstate": ["error"],
"react/button-has-type": [
"error",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.7",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0"
},
"dependencies": {
Expand All @@ -55,7 +55,7 @@
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.7",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.2",
"jest": "^29.3.1",
Expand Down
6 changes: 3 additions & 3 deletions tests/validate-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe('Validate configs by eslint', () => {
const results = await getErrors();
const errorMessages = results[0].messages;
expect(errorMessages).toHaveLength(3);
expect(errorMessages[0].ruleId).toBe('no-multi-spaces');
expect(errorMessages[1].ruleId).toBe('no-console');
expect(errorMessages[2].ruleId).toBe('no-multiple-empty-lines');
expect(errorMessages[0].ruleId).toBe('comma-dangle');
expect(errorMessages[1].ruleId).toBe('no-multi-spaces');
expect(errorMessages[2].ruleId).toBe('no-console');
});
});
Loading

0 comments on commit 2f7ddbb

Please sign in to comment.