Skip to content

Commit

Permalink
IBX-9109: Added support for TypeScript (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
OstafinL authored Dec 9, 2024
1 parent edf236a commit 52ec34d
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 50 deletions.
140 changes: 90 additions & 50 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
const baseRules = {
"array-callback-return": "error",
"eol-last": "error",
"no-console": ["error", { allow: ["warn", "error"] }],
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-extra-boolean-cast": "off",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { "max": 1, "maxBOF": 0, "maxEOF": 0 }],
"no-nested-ternary": "error",
"no-shadow": "error",
"no-template-curly-in-string": "error",
"no-trailing-spaces": "error",
"no-unreachable-loop": "error",
"no-unsafe-optional-chaining": "error",
"no-useless-concat": "error",
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"prefer-destructuring": ["error", {
"VariableDeclarator": {
"array": false,
"object": true
},
"AssignmentExpression": {
"array": false,
"object": false
}
}, { enforceForRenamedProperties: false }],
"prefer-object-spread": "error",
"prefer-template": "error",
"quotes": ["error", "single", { allowTemplateLiterals: true }],
"radix": "error",
"semi-spacing": "error",
"react/button-has-type": "error",
"react/default-props-match-prop-types": "error",
"react/jsx-boolean-value": ["error", "always"],
"react/jsx-closing-bracket-location": "error",
"react/jsx-closing-tag-location": "error",
"react/jsx-curly-spacing": "error",
"react/jsx-equals-spacing": "error",
"react/jsx-first-prop-new-line": "error",
"react/jsx-key": "error",
"react/jsx-no-duplicate-props": "error",
"react/no-array-index-key": "error",
"react/no-typos": "error",
"react/require-default-props": "error",
"react/self-closing-comp": "error",
"react/style-prop-object": "error",
};

module.exports = {
plugins: ["react"],
extends: ["eslint:recommended", "plugin:react/recommended"],
settings: {
react: {
version: "16.x"
Expand All @@ -22,54 +71,45 @@ module.exports = {
sourceType: "module",
ecmaVersion: 12
},
rules: {
"array-callback-return": "error",
"eol-last": "error",
"no-console": ["error", { allow: ["warn", "error"] }],
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-extra-boolean-cast": "off",
"no-multi-spaces": "error",
"no-multiple-empty-lines": ["error", { "max": 1, "maxBOF": 0, "maxEOF": 0 }],
"no-nested-ternary": "error",
"no-shadow": "error",
"no-template-curly-in-string": "error",
"no-trailing-spaces": "error",
"no-unreachable-loop": "error",
"no-unsafe-optional-chaining": "error",
"no-useless-concat": "error",
"no-var": "error",
"object-curly-spacing": ["error", "always"],
"prefer-const": "error",
"prefer-destructuring": ["error", {
"VariableDeclarator": {
"array": false,
"object": true
overrides: [
{
files: ["*.js"],
plugins: ["react"],
extends: ["eslint:recommended", "plugin:react/recommended"],
rules: baseRules
},
{
files: ["*.ts", "*.tsx"],
parserOptions: {
project: './tsconfig.eslint.json',
},
"AssignmentExpression": {
"array": false,
"object": false
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked"
],
rules: {
...baseRules,
...{
"@typescript-eslint/no-unsafe-type-assertion": "error",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/typedef": [
"error",
{
"arrayDestructuring": true,
"arrowParameter": true,
"memberVariableDeclaration": true,
"objectDestructuring": true,
"parameter": true,
"propertyDeclaration": true,
"variableDeclaration": false,
"variableDeclarationIgnoreFunction": false,
},
],
"react/style-prop-object": "error",
"react/require-default-props": "off"
}
}
}, { enforceForRenamedProperties: false }],
"prefer-object-spread": "error",
"prefer-template": "error",
"quotes": ["error", "single", { allowTemplateLiterals: true }],
"radix": "error",
"semi-spacing": "error",
"react/button-has-type": "error",
"react/default-props-match-prop-types": "error",
"react/jsx-boolean-value": ["error", "always"],
"react/jsx-closing-bracket-location": "error",
"react/jsx-closing-tag-location": "error",
"react/jsx-curly-spacing": "error",
"react/jsx-equals-spacing": "error",
"react/jsx-first-prop-new-line": "error",
"react/jsx-key": "error",
"react/jsx-no-duplicate-props": "error",
"react/no-array-index-key": "error",
"react/no-typos": "error",
"react/require-default-props": "error",
"react/self-closing-comp": "error",
"react/style-prop-object": "error"
}
}
]
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"repository": "[email protected]:ibexa/eslint-config-ibexa.git",
"private": true,
"dependencies": {
"@typescript-eslint/eslint-plugin": "8.16.0",
"@typescript-eslint/parser": "8.16.0",
"typescript": "5.6.3",
"eslint": "8.55",
"eslint-plugin-react": "7.33.2",
"prettier": "3.1"
Expand Down

0 comments on commit 52ec34d

Please sign in to comment.