@widergy/eslint-config 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,28 @@
1
+ version: 2
2
+
3
+ aliases:
4
+ - &widergy-context
5
+ context:
6
+ - widergy-aws-github
7
+
8
+ jobs:
9
+ release:
10
+ docker:
11
+ - image: cimg/node:22.18.0
12
+ steps:
13
+ - checkout
14
+ - run: yarn install
15
+
16
+ - run: npx semantic-release
17
+
18
+
19
+ workflows:
20
+ version: 2
21
+ test_and_release:
22
+ jobs:
23
+ - release:
24
+ <<: *widergy-context
25
+ filters:
26
+ branches:
27
+ only:
28
+ - master
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # eslint-config
@@ -0,0 +1,41 @@
1
+ import { defineConfig } from "eslint/config";
2
+ import js from "@eslint/js";
3
+ import importPlugin from "eslint-plugin-import";
4
+ import prettierPlugin from "eslint-plugin-prettier";
5
+ import babelParser from "@babel/eslint-parser";
6
+
7
+ export default defineConfig([
8
+ js.configs.recommended,
9
+ {
10
+ ignores: ["node_modules/**", "dist/**", "build/**"],
11
+ languageOptions: {
12
+ globals: {},
13
+ parser: babelParser,
14
+ parserOptions: {
15
+ ecmaVersion: "latest",
16
+ requireConfigFile: false,
17
+ sourceType: "module",
18
+ },
19
+ },
20
+ name: "internal-config",
21
+ plugins: {
22
+ import: importPlugin,
23
+ prettier: prettierPlugin,
24
+ },
25
+ rules: {
26
+ "sort-keys": [
27
+ "error",
28
+ "asc",
29
+ { allowLineSeparatedGroups: true, caseSensitive: false, natural: true },
30
+ ],
31
+ },
32
+ settings: {
33
+ "import/resolver": {
34
+ node: {
35
+ extensions: [".js", ".mjs", ".cjs", ".json"],
36
+ moduleDirectory: ["node_modules", "src/"],
37
+ },
38
+ },
39
+ },
40
+ },
41
+ ]);
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@widergy/eslint-config",
3
+ "version": "1.0.0",
4
+ "description": "Widergy ESLint configuration",
5
+ "type": "module",
6
+ "author": "widergy",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/widergy/eslint-config.git"
11
+ },
12
+ "main": "./src/index.js",
13
+ "exports": {
14
+ "./javascript": "./src/javascript.js",
15
+ "./react": "./src/react.js",
16
+ "./react-native": "./src/react-native.js"
17
+ },
18
+ "keywords": [
19
+ "eslint",
20
+ "config",
21
+ "widergy"
22
+ ],
23
+ "scripts": {
24
+ "lint": "eslint ."
25
+ },
26
+ "peerDependencies": {
27
+ "@babel/core": "^7.22.10",
28
+ "@babel/eslint-parser": "^7.22.10",
29
+ "@babel/preset-typescript": "^7.28.0",
30
+ "@eslint/compat": "^1.4.0",
31
+ "@eslint/eslintrc": "^3.3.0",
32
+ "@eslint/js": "^9.0.0",
33
+ "@react-native/babel-preset": "^0.80.0",
34
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
35
+ "@typescript-eslint/parser": "^6.21.0",
36
+ "eslint": "^9.0.0",
37
+ "eslint-config-airbnb": "^19.0.0",
38
+ "eslint-import-resolver-babel-module": "^5.3.0",
39
+ "eslint-import-resolver-typescript": "^4.4.4",
40
+ "eslint-plugin-import": "^2.32.0",
41
+ "eslint-plugin-jsx-a11y": "^6.10.0",
42
+ "eslint-plugin-prettier": "^5.0.0",
43
+ "eslint-plugin-react": "^7.37.0",
44
+ "eslint-plugin-react-hooks": "^5.2.0",
45
+ "eslint-plugin-react-native": "^5.0.0",
46
+ "globals": "^16.4.0",
47
+ "prettier": "^3.0.0",
48
+ "typescript": "^5.0.0",
49
+ "typescript-eslint": "^8.46.4"
50
+ },
51
+ "devDependencies": {
52
+ "@babel/core": "^7.22.10",
53
+ "@babel/eslint-parser": "^7.22.10",
54
+ "@babel/preset-typescript": "^7.28.0",
55
+ "@eslint/compat": "^1.4.0",
56
+ "@eslint/eslintrc": "^3.3.0",
57
+ "@eslint/js": "^9.0.0",
58
+ "@react-native/babel-preset": "^0.80.0",
59
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
60
+ "@typescript-eslint/parser": "^6.21.0",
61
+ "eslint": "^9.0.0",
62
+ "eslint-config-airbnb": "^19.0.0",
63
+ "eslint-import-resolver-babel-module": "^5.3.0",
64
+ "eslint-import-resolver-typescript": "^4.4.4",
65
+ "eslint-plugin-import": "^2.32.0",
66
+ "eslint-plugin-jsx-a11y": "^6.10.2",
67
+ "eslint-plugin-prettier": "^5.0.0",
68
+ "eslint-plugin-react": "^7.37.0",
69
+ "eslint-plugin-react-hooks": "^5.2.0",
70
+ "eslint-plugin-react-native": "^5.0.0",
71
+ "globals": "^16.4.0",
72
+ "prettier": "^3.0.0",
73
+ "typescript": "^5.0.0",
74
+ "typescript-eslint": "^8.46.4",
75
+ "@widergy/semantic-release-package-config": "^1.0.0",
76
+ "semantic-release": "^15.13.31"
77
+ },
78
+ "release": {
79
+ "extends": "@widergy/semantic-release-package-config"
80
+ }
81
+ }
@@ -0,0 +1,113 @@
1
+ import js from "@eslint/js";
2
+ import babelParser from "@babel/eslint-parser";
3
+ import { defineConfig } from "eslint/config";
4
+ import importPlugin from "eslint-plugin-import";
5
+ import prettierPlugin from "eslint-plugin-prettier";
6
+ import globals from "globals";
7
+ import tseslint from "typescript-eslint";
8
+
9
+ import { compat } from "./utils.js";
10
+ import { baseRules, jsOnlyRules, tsOnlyRules } from "./rules/baseRules.js";
11
+ import { prettierRules } from "./rules/prettierRules.js";
12
+ import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
13
+ import { importRules } from "./rules/importRules.js";
14
+
15
+ const tsConfigs = tseslint.configs.recommendedTypeChecked.map((config) => ({
16
+ ...config,
17
+ files: ["**/*.{ts,tsx}"],
18
+ }));
19
+
20
+ export default defineConfig([
21
+ js.configs.recommended,
22
+
23
+ ...fixupConfigRules(
24
+ compat.extends("plugin:import/recommended", "plugin:prettier/recommended"),
25
+ ),
26
+
27
+ ...tsConfigs,
28
+
29
+ {
30
+ files: ["**/*.{js,jsx,ts,tsx}"],
31
+ ignores: ["node_modules/**", "dist/**", "build/**"],
32
+ languageOptions: {
33
+ ecmaVersion: "latest",
34
+ globals: {
35
+ ...globals.node,
36
+ ...globals.browser,
37
+ __DEV__: "readonly",
38
+ },
39
+ sourceType: "module",
40
+ },
41
+ linterOptions: {
42
+ reportUnusedDisableDirectives: "error",
43
+ },
44
+ name: "widergy/javascript",
45
+ plugins: {
46
+ import: fixupPluginRules(importPlugin),
47
+ prettier: fixupPluginRules(prettierPlugin),
48
+ },
49
+ rules: {
50
+ ...baseRules,
51
+ ...prettierRules,
52
+ ...importRules,
53
+ },
54
+ settings: {
55
+ "import/resolver": {
56
+ "babel-module": {},
57
+ node: {
58
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
59
+ moduleDirectory: ["node_modules", "src/"],
60
+ },
61
+ typescript: {
62
+ project: "./tsconfig.json",
63
+ },
64
+ },
65
+ },
66
+ },
67
+
68
+ {
69
+ files: ["**/*.js", "**/*.jsx"],
70
+ languageOptions: {
71
+ parser: babelParser,
72
+ parserOptions: {
73
+ babelOptions: {
74
+ babelrc: false,
75
+ configFile: false,
76
+ plugins: [
77
+ "import-glob",
78
+ [
79
+ "module-resolver",
80
+ {
81
+ root: ["./src"],
82
+ },
83
+ ],
84
+ ],
85
+ presets: ["@babel/preset-env"],
86
+ },
87
+ ecmaFeatures: {
88
+ jsx: true,
89
+ },
90
+ requireConfigFile: false,
91
+ },
92
+ },
93
+ name: "widergy/javascript-js",
94
+ rules: {
95
+ ...jsOnlyRules,
96
+ },
97
+ },
98
+
99
+ {
100
+ files: ["**/*.ts", "**/*.tsx"],
101
+ languageOptions: {
102
+ parser: tseslint.parser,
103
+ parserOptions: {
104
+ projectService: true,
105
+ tsconfigRootDir: import.meta.dirname,
106
+ },
107
+ },
108
+ name: "widergy/javascript-ts",
109
+ rules: {
110
+ ...tsOnlyRules,
111
+ },
112
+ },
113
+ ]);
@@ -0,0 +1,136 @@
1
+ import js from "@eslint/js";
2
+ import importPlugin from "eslint-plugin-import";
3
+ import prettierPlugin from "eslint-plugin-prettier";
4
+ import reactPlugin from "eslint-plugin-react";
5
+ import reactHooksPlugin from "eslint-plugin-react-hooks";
6
+ import reactNativePlugin from "eslint-plugin-react-native";
7
+ import babelParser from "@babel/eslint-parser";
8
+ import { defineConfig } from "eslint/config";
9
+ import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
10
+ import globals from "globals";
11
+ import tseslint from "typescript-eslint";
12
+
13
+ import { compat } from "./utils.js";
14
+ import { baseRules, jsOnlyRules, tsOnlyRules } from "./rules/baseRules.js";
15
+ import { prettierRules } from "./rules/prettierRules.js";
16
+ import { importRules } from "./rules/importRules.js";
17
+ import { reactRules } from "./rules/reactRules.js";
18
+ import { reactNativeRules } from "./rules/reactNativeRules.js";
19
+ import { reactHooksRules } from "./rules/reactHooksRules.js";
20
+
21
+ const tsConfigs = tseslint.configs.recommendedTypeChecked.map((config) => ({
22
+ ...config,
23
+ files: ["**/*.{ts,tsx}"],
24
+ }));
25
+
26
+ export default defineConfig([
27
+ js.configs.recommended,
28
+
29
+ ...fixupConfigRules(
30
+ compat.extends(
31
+ "airbnb",
32
+ "plugin:import/recommended",
33
+ "plugin:prettier/recommended",
34
+ "plugin:react/recommended",
35
+ "plugin:react-hooks/recommended",
36
+ "plugin:react-native/all",
37
+ ),
38
+ ),
39
+
40
+ ...tsConfigs,
41
+
42
+ {
43
+ files: ["**/*.{js,jsx,ts,tsx}"],
44
+ ignores: ["node_modules/**", "dist/**", "build/**", "ios/**", "android/**"],
45
+ languageOptions: {
46
+ ecmaVersion: "latest",
47
+ globals: {
48
+ ...globals.node,
49
+ ...globals.browser,
50
+ __DEV__: "readonly",
51
+ },
52
+ sourceType: "module",
53
+ },
54
+ linterOptions: {
55
+ reportUnusedDisableDirectives: "error",
56
+ },
57
+ name: "widergy/react-native",
58
+ plugins: {
59
+ import: fixupPluginRules(importPlugin),
60
+ prettier: fixupPluginRules(prettierPlugin),
61
+ react: fixupPluginRules(reactPlugin),
62
+ "react-hooks": fixupPluginRules(reactHooksPlugin),
63
+ "react-native": fixupPluginRules(reactNativePlugin),
64
+ },
65
+ rules: {
66
+ ...baseRules,
67
+ ...prettierRules,
68
+ ...importRules,
69
+ ...reactRules,
70
+ ...reactHooksRules,
71
+ ...reactNativeRules,
72
+ },
73
+ settings: {
74
+ "import/resolver": {
75
+ "babel-module": {},
76
+ node: {
77
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
78
+ moduleDirectory: ["node_modules", "src"],
79
+ },
80
+ typescript: {
81
+ project: "./tsconfig.json",
82
+ },
83
+ },
84
+ react: {
85
+ version: "detect",
86
+ },
87
+ },
88
+ },
89
+
90
+ {
91
+ files: ["**/*.js", "**/*.jsx"],
92
+ languageOptions: {
93
+ parser: babelParser,
94
+ parserOptions: {
95
+ babelOptions: {
96
+ babelrc: false,
97
+ configFile: false,
98
+ plugins: [
99
+ "import-glob",
100
+ [
101
+ "module-resolver",
102
+ {
103
+ root: ["./src"],
104
+ },
105
+ ],
106
+ "react-native-worklets/plugin",
107
+ ],
108
+ presets: ["module:@react-native/babel-preset"],
109
+ },
110
+ ecmaFeatures: {
111
+ jsx: true,
112
+ },
113
+ requireConfigFile: false,
114
+ },
115
+ },
116
+ name: "widergy/react-native-js",
117
+ rules: {
118
+ ...jsOnlyRules,
119
+ },
120
+ },
121
+
122
+ {
123
+ files: ["**/*.{ts,tsx}"],
124
+ languageOptions: {
125
+ parser: tseslint.parser,
126
+ parserOptions: {
127
+ projectService: true,
128
+ tsconfigRootDir: import.meta.dirname,
129
+ },
130
+ },
131
+ name: "widergy/react-native-ts",
132
+ rules: {
133
+ ...tsOnlyRules,
134
+ },
135
+ },
136
+ ]);
package/src/react.js ADDED
@@ -0,0 +1,132 @@
1
+ import js from "@eslint/js";
2
+ import importPlugin from "eslint-plugin-import";
3
+ import prettierPlugin from "eslint-plugin-prettier";
4
+ import reactPlugin from "eslint-plugin-react";
5
+ import reactHooksPlugin from "eslint-plugin-react-hooks";
6
+ import babelParser from "@babel/eslint-parser";
7
+ import globals from "globals";
8
+ import tseslint from "typescript-eslint";
9
+
10
+ import { baseRules, jsOnlyRules, tsOnlyRules } from "./rules/baseRules.js";
11
+ import { importRules } from "./rules/importRules.js";
12
+ import { prettierRules } from "./rules/prettierRules.js";
13
+ import { reactRules } from "./rules/reactRules.js";
14
+ import { reactHooksRules } from "./rules/reactHooksRules.js";
15
+ import { jsxA11yRules } from "./rules/jsxA11yRules.js";
16
+ import { compat } from "./utils.js";
17
+ import { defineConfig } from "eslint/config";
18
+ import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
19
+
20
+ const tsConfigs = tseslint.configs.recommendedTypeChecked.map((config) => ({
21
+ ...config,
22
+ files: ["**/*.{ts,tsx}"],
23
+ }));
24
+
25
+ export default defineConfig([
26
+ js.configs.recommended,
27
+
28
+ ...fixupConfigRules(
29
+ compat.extends(
30
+ "airbnb",
31
+ "plugin:import/recommended",
32
+ "plugin:prettier/recommended",
33
+ "plugin:react/recommended",
34
+ "plugin:react-hooks/recommended",
35
+ ),
36
+ ),
37
+
38
+ ...tsConfigs,
39
+
40
+ {
41
+ files: ["**/*.{js,jsx,ts,tsx}"], // add support for scss files, possibly deprecating node-sass/sass-lint for sass/stylelint
42
+ ignores: ["node_modules/**", "dist/**", "build/**"],
43
+ languageOptions: {
44
+ ecmaVersion: "latest",
45
+ globals: {
46
+ ...globals.node,
47
+ ...globals.browser,
48
+ __DEV__: "readonly",
49
+ },
50
+ sourceType: "module",
51
+ },
52
+ linterOptions: {
53
+ reportUnusedDisableDirectives: "error",
54
+ },
55
+ name: "widergy/react-web",
56
+ plugins: {
57
+ import: fixupPluginRules(importPlugin),
58
+ prettier: fixupPluginRules(prettierPlugin),
59
+ react: fixupPluginRules(reactPlugin),
60
+ "react-hooks": fixupPluginRules(reactHooksPlugin),
61
+ },
62
+ rules: {
63
+ ...baseRules,
64
+ ...prettierRules,
65
+ ...importRules,
66
+ ...reactRules,
67
+ ...reactHooksRules,
68
+ ...jsxA11yRules,
69
+ },
70
+ settings: {
71
+ "import/resolver": {
72
+ "babel-module": {},
73
+ node: {
74
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
75
+ moduleDirectory: ["node_modules", "src/"],
76
+ },
77
+ typescript: {
78
+ project: "./tsconfig.json",
79
+ },
80
+ },
81
+ react: {
82
+ version: "detect",
83
+ },
84
+ },
85
+ },
86
+
87
+ {
88
+ files: ["**/*.js", "**/*.jsx"],
89
+ languageOptions: {
90
+ parser: babelParser,
91
+ parserOptions: {
92
+ babelOptions: {
93
+ babelrc: false,
94
+ configFile: false,
95
+ plugins: [
96
+ "import-glob",
97
+ [
98
+ "module-resolver",
99
+ {
100
+ root: ["./src"],
101
+ },
102
+ ],
103
+ ],
104
+ presets: ["@babel/preset-react"],
105
+ },
106
+ ecmaFeatures: {
107
+ jsx: true,
108
+ },
109
+ requireConfigFile: false,
110
+ },
111
+ },
112
+ name: "widergy/react-web-js",
113
+ rules: {
114
+ ...jsOnlyRules,
115
+ },
116
+ },
117
+
118
+ {
119
+ files: ["**/*.{ts,tsx}"],
120
+ languageOptions: {
121
+ parser: tseslint.parser,
122
+ parserOptions: {
123
+ projectService: true,
124
+ tsconfigRootDir: import.meta.dirname,
125
+ },
126
+ },
127
+ name: "widergy/react-web-ts",
128
+ rules: {
129
+ ...tsOnlyRules,
130
+ },
131
+ },
132
+ ]);
@@ -0,0 +1,44 @@
1
+ export const baseRules = {
2
+ camelcase: "off",
3
+ "class-methods-use-this": "off",
4
+ "consistent-return": "off",
5
+ "func-names": ["error", "always"],
6
+ "lines-between-class-members": "off",
7
+ "max-classes-per-file": "off",
8
+ "no-alert": "error",
9
+ "no-console": "error",
10
+ "no-else-return": "off",
11
+ "no-nested-ternary": "off",
12
+ "no-param-reassign": "off",
13
+ "no-plusplus": "off",
14
+ "no-restricted-exports": "off",
15
+ "no-restricted-globals": "off",
16
+ "no-underscore-dangle": "off",
17
+ "one-var": "off",
18
+ };
19
+
20
+ export const jsOnlyRules = {
21
+ "no-unused-vars": [
22
+ "error",
23
+ {
24
+ args: "all",
25
+ argsIgnorePattern: "^_",
26
+ caughtErrorsIgnorePattern: "^_",
27
+ destructuredArrayIgnorePattern: "^_",
28
+ varsIgnorePattern: "^_",
29
+ },
30
+ ],
31
+ };
32
+
33
+ export const tsOnlyRules = {
34
+ "@typescript-eslint/no-unused-vars": [
35
+ "error",
36
+ {
37
+ args: "all",
38
+ argsIgnorePattern: "^_",
39
+ caughtErrorsIgnorePattern: "^_",
40
+ destructuredArrayIgnorePattern: "^_",
41
+ varsIgnorePattern: "^_",
42
+ },
43
+ ],
44
+ };
@@ -0,0 +1,20 @@
1
+ export const importRules = {
2
+ "import/extensions": "off",
3
+ "import/no-absolute-path": "error",
4
+ "import/no-cycle": "off",
5
+ "import/no-extraneous-dependencies": "off",
6
+ "import/order": [
7
+ "error",
8
+ {
9
+ groups: [
10
+ "external",
11
+ ["builtin", "internal"],
12
+ "parent",
13
+ "sibling",
14
+ "index",
15
+ ],
16
+ "newlines-between": "always",
17
+ },
18
+ ],
19
+ "import/prefer-default-export": "off",
20
+ };
@@ -0,0 +1,13 @@
1
+ export const jsxA11yRules = {
2
+ "jsx-a11y/anchor-is-valid": [
3
+ "error",
4
+ {
5
+ components: ["Link"],
6
+ specialLink: ["to"],
7
+ },
8
+ ],
9
+ "jsx-a11y/interactive-supports-focus": "off",
10
+ "jsx-a11y/media-has-caption": "off",
11
+ "jsx-a11y/no-noninteractive-element-interactions": "off",
12
+ "jsx-a11y/no-noninteractive-element-to-interactive-role": "off",
13
+ };
@@ -0,0 +1,16 @@
1
+ export const prettierRules = {
2
+ "prettier/prettier": [
3
+ "error",
4
+ {
5
+ arrowParens: "avoid",
6
+ bracketSameLine: false,
7
+ bracketSpacing: true,
8
+ printWidth: 110,
9
+ singleQuote: true,
10
+ trailingComma: "none",
11
+ },
12
+ {
13
+ usePrettierrc: false,
14
+ },
15
+ ],
16
+ };
@@ -0,0 +1,4 @@
1
+ export const reactHooksRules = {
2
+ "react-hooks/exhaustive-deps": "off", // TODO: validar
3
+ "react-hooks/rules-of-hooks": "error",
4
+ };
@@ -0,0 +1,5 @@
1
+ export const reactNativeRules = {
2
+ // "react-native/no-color-literals": "off", // TODO: validar
3
+ "react-native/no-raw-text": "off",
4
+ "react-native/split-platform-components": "off",
5
+ };
@@ -0,0 +1,32 @@
1
+ export const reactRules = {
2
+ "react/button-has-type": "off",
3
+ "react/destructuring-assignment": "off",
4
+ "react/forbid-foreign-prop-types": "off",
5
+ "react/function-component-definition": [
6
+ "error",
7
+ {
8
+ namedComponents: "arrow-function",
9
+ unnamedComponents: "arrow-function",
10
+ },
11
+ ],
12
+ "react/jsx-filename-extension": [
13
+ "error",
14
+ { extensions: [".js", ".jsx", ".ts", ".tsx"] },
15
+ ],
16
+ "react/jsx-indent": "off",
17
+ "react/jsx-one-expression-per-line": "off",
18
+ "react/jsx-props-no-spreading": "off",
19
+ "react/jsx-wrap-multilines": "off",
20
+ // "react/jsx-fragments": ["error", "syntax"], // TODO: validar
21
+ // "react/no-access-state-in-setstate": "off", // TODO: no salta
22
+ "react/no-typos": "off",
23
+ // "react/no-unstable-nested-components": "off", // TODO: validar
24
+ // "react/prefer-stateless-function": "off", // TODO: no salta
25
+ "react/prop-types": [
26
+ "error",
27
+ {
28
+ ignore: ["style", "children", "dispatch", "navigation", "route", "theme"],
29
+ },
30
+ ],
31
+ "react/require-default-props": "off",
32
+ };
package/src/utils.js ADDED
@@ -0,0 +1,10 @@
1
+ import { FlatCompat } from "@eslint/eslintrc";
2
+ import { fileURLToPath } from "url";
3
+ import path from "path";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ export const compat = new FlatCompat({
9
+ baseDirectory: __dirname,
10
+ });