Skip to content

Commit

Permalink
Merge pull request #12 from DNepovim/version-3.4.0
Browse files Browse the repository at this point in the history
Version 4.0.0
  • Loading branch information
gius authored Mar 22, 2024
2 parents 8fba467 + 4eac4c9 commit fe3712d
Show file tree
Hide file tree
Showing 7 changed files with 637 additions and 633 deletions.
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Inspired by https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-types

## Versions

eslint-config v4 refactor rules and divide config for node and react

eslint-config v3 supports ESlint 8.

eslint-config v2 requires ESlint 7.
Expand All @@ -20,11 +22,13 @@ Install ESlint:

Update config files as follows:

(use correct config, eslint-node for backend and eslint-react for frontend)

### `.eslintrc.js`

module.exports = {
extends: [
"@emanprague/eslint-config/eslint-default"
"@emanprague/eslint-config/eslint-[node|react]"
],
settings: {
react: {
Expand All @@ -34,15 +38,7 @@ Update config files as follows:
env: {
browser: true,
},
};

### `.prettierrc.js`

module.exports = require("@emanprague/eslint-config/prettier-config");

Note that instead of creating the `.prettierrc.js` file, you can just add the following row to your `package.json` file.

"prettier": "@emanprague/eslint-config/prettier-config",
}

---

Expand All @@ -55,6 +51,7 @@ eslint \"./src/**/*.{ts,tsx}\" --cache
# Contribution

How to release:
1. manually set version in package.json
1. push
1. create a new release in GH

1. manually set version in package.json
1. push
1. create a new release in GH
56 changes: 31 additions & 25 deletions eslint-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,51 @@ module.exports = {
project: ["tsconfig.json"],
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
plugins: ["@typescript-eslint", "sonarjs"],
plugins: ["@typescript-eslint", "sonarjs", "unused-imports"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:react/recommended",
"plugin:sonarjs/recommended",
"plugin:eslint-comments/recommended",
"prettier", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
"plugin:sonarjs/recommended",
"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.
"prettier", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
],
overrides: [
{
files: ["*.test.{ts,tsx}"],
rules: {
"sonarjs/no-duplicate-string": "off",
},
},
],
rules: {
curly: ["error", "all"],
"no-console": "warn",
"no-unneeded-ternary": "error",
"no-redeclare": "off", // warns on typescript function overrides
//"@typescript-eslint/no-redeclare": ["error"], // this should be enabled, but causes 'Definition for rule '@typescript-eslint/no-redeclare' was not found'

"react/prop-types": "off",
"react/display-name": "off",
"react/jsx-curly-brace-presence": ["error", "never"],
"react/react-in-jsx-scope": "off",
"prettier/prettier": [
"error",
{
trailingComma: "es5",
bracketSameLine: true,
endOfLine: "auto",
printWidth: 130,
arrowParens: "avoid",
},
],

"eslint-comments/no-unused-disable": "error",
"eslint-comments/disable-enable-pair": ["error", {"allowWholeFile": true}],
"eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],

"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{ args: "none", ignoreRestSiblings: true },
],
"@typescript-eslint/no-use-before-define": "off", // disabled because it can report incorrect errors https://stackoverflow.com/a/64024916/19712
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": ["warn"],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/consistent-type-exports": "warn",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
Expand All @@ -50,6 +59,7 @@ module.exports = {
"@typescript-eslint/non-nullable-type-assertion-style": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-includes": "warn",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/prefer-nullish-coalescing": [
"warn",
{
Expand All @@ -59,10 +69,6 @@ module.exports = {
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
"@typescript-eslint/no-throw-literal": "error",
},
settings: {
react: {
version: "detect", // Tells eslint-plugin-react to automatically detect the version of React to use
},
"@typescript-eslint/prefer-enum-initializers": "error",
},
};
13 changes: 13 additions & 0 deletions eslint-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["jest"],
extends: ["plugin:jest/recommended", "./eslint-default.js"],
rules: {
curly: ["error", "all"],
"react/prop-types": "off",
"react/display-name": "off",
"react/jsx-curly-brace-presence": ["error", "never"],
"react/react-in-jsx-scope": "off",
"react/jsx-key": ["warn"],
},
};
28 changes: 28 additions & 0 deletions eslint-react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
plugins: ["react", "vitest"],
extends: [
"plugin:react/recommended",
"plugin:storybook/recommended",
"plugin:vitest/recommended",
"./eslint-default.js",
],
rules: {
curly: ["error", "all"],
"react/prop-types": "off",
"react/display-name": "off",
"react/jsx-curly-brace-presence": ["error", "never"],
"react/react-in-jsx-scope": "off",
"react/jsx-key": ["warn"],
},
settings: {
react: {
version: "detect", // Tells eslint-plugin-react to automatically detect the version of React to use
},
},
};
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@emanprague/eslint-config",
"version": "3.3.0",
"version": "4.0.0",
"description": "ESlint and prettier configurations",
"main": "eslint-config.js",
"repository": "https://github.com/eManPrague/eslint-config.git",
Expand All @@ -19,16 +19,22 @@
"author": "Augustin Sulc <[email protected]>",
"license": "MIT",
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-sonarjs": "^0.21.0",
"typescript": "^5.2.2"
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-storybook": "^0.6.15",
"eslint-plugin-unused-imports": "^3.0.0",
"eslint-plugin-vitest": "^0.3.20",
"typescript": "^5.3.3"
},
"peerDependencies": {
"eslint": "^8.4.1"
"eslint": "^8.01.0",
"jest": "^29.7.0",
"prettier": "^2.8.0"
}
}
7 changes: 0 additions & 7 deletions prettier-config.js

This file was deleted.

Loading

0 comments on commit fe3712d

Please sign in to comment.