@kembec/eslint-config 1.1.2 → 2.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.
Files changed (43) hide show
  1. package/README.md +74 -0
  2. package/commit.log +2 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +87 -0
  5. package/coverage/lcov-report/eslint-config-kembec/eslint.config.js.html +94 -0
  6. package/coverage/lcov-report/eslint-config-kembec/index.html +116 -0
  7. package/coverage/lcov-report/eslint-config-kembec/index.js.html +145 -0
  8. package/coverage/lcov-report/eslint-config-kembec/presets/index.html +161 -0
  9. package/coverage/lcov-report/eslint-config-kembec/presets/js.js.html +208 -0
  10. package/coverage/lcov-report/eslint-config-kembec/presets/react.js.html +244 -0
  11. package/coverage/lcov-report/eslint-config-kembec/presets/ts.js.html +214 -0
  12. package/coverage/lcov-report/eslint-config-kembec/presets/vitest.js.html +124 -0
  13. package/coverage/lcov-report/eslint-config-kembec/rules/best-practices.js.html +160 -0
  14. package/coverage/lcov-report/eslint-config-kembec/rules/errors.js.html +163 -0
  15. package/coverage/lcov-report/eslint-config-kembec/rules/index.html +176 -0
  16. package/coverage/lcov-report/eslint-config-kembec/rules/plugins.js.html +256 -0
  17. package/coverage/lcov-report/eslint-config-kembec/rules/style.js.html +106 -0
  18. package/coverage/lcov-report/eslint-config-kembec/rules/typescript.js.html +280 -0
  19. package/coverage/lcov-report/favicon.png +0 -0
  20. package/coverage/lcov-report/index.html +146 -0
  21. package/coverage/lcov-report/prettify.css +1 -0
  22. package/coverage/lcov-report/prettify.js +2 -0
  23. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  24. package/coverage/lcov-report/sorter.js +210 -0
  25. package/coverage/lcov.info +125 -0
  26. package/index.js +20 -18
  27. package/package.json +44 -23
  28. package/presets/js.js +41 -0
  29. package/presets/react.js +53 -0
  30. package/presets/ts.js +43 -0
  31. package/presets/vitest.js +13 -0
  32. package/rules/best-practices.js +3 -2
  33. package/rules/errors.js +3 -1
  34. package/rules/plugins.js +56 -46
  35. package/rules/style.js +2 -5
  36. package/rules/typescript.js +17 -20
  37. package/.eslintrc +0 -3
  38. package/.github/workflows/npm-publish.yaml +0 -22
  39. package/Readme.md +0 -76
  40. package/jest/index.js +0 -11
  41. package/rules/variables.js +0 -7
  42. package/typescript/index.js +0 -28
  43. package/typescript/jest/index.js +0 -11
package/presets/js.js ADDED
@@ -0,0 +1,41 @@
1
+ import js from "@eslint/js";
2
+ import prettierConfig from "eslint-config-prettier";
3
+ import importXPlugin from "eslint-plugin-import-x";
4
+ import globals from "globals";
5
+
6
+ import bestPractices from "../rules/best-practices.js";
7
+ import errors from "../rules/errors.js";
8
+ import { importXRules, pluginInstances, pluginRules } from "../rules/plugins.js";
9
+ import style from "../rules/style.js";
10
+
11
+ export function buildJsPreset() {
12
+ return [
13
+ js.configs.recommended,
14
+ prettierConfig,
15
+ {
16
+ files: ["**/*.{js,jsx,mjs,cjs}"],
17
+ languageOptions: {
18
+ ecmaVersion: "latest",
19
+ sourceType: "module",
20
+ globals: {
21
+ ...globals.browser,
22
+ ...globals.es2022,
23
+ ...globals.node,
24
+ },
25
+ },
26
+ plugins: {
27
+ ...pluginInstances,
28
+ "import-x": importXPlugin,
29
+ },
30
+ rules: {
31
+ ...bestPractices.rules,
32
+ ...errors.rules,
33
+ ...style.rules,
34
+ ...pluginRules,
35
+ ...importXRules,
36
+ },
37
+ },
38
+ ];
39
+ }
40
+
41
+ export default buildJsPreset();
@@ -0,0 +1,53 @@
1
+ import prettierConfig from "eslint-config-prettier";
2
+ import importXPlugin from "eslint-plugin-import-x";
3
+ import reactPlugin from "eslint-plugin-react";
4
+ import reactHooksPlugin from "eslint-plugin-react-hooks";
5
+ import globals from "globals";
6
+ import tseslint from "typescript-eslint";
7
+
8
+ import bestPractices from "../rules/best-practices.js";
9
+ import errors from "../rules/errors.js";
10
+ import { importXRules, pluginInstances, pluginRules } from "../rules/plugins.js";
11
+ import style from "../rules/style.js";
12
+ import typescriptRules from "../rules/typescript.js";
13
+
14
+ export function buildReactPreset(tsconfigPath = "./tsconfig.json") {
15
+ return tseslint.config(prettierConfig, ...tseslint.configs.recommendedTypeChecked, {
16
+ files: ["**/*.{ts,tsx}"],
17
+ languageOptions: {
18
+ ecmaVersion: "latest",
19
+ sourceType: "module",
20
+ globals: {
21
+ ...globals.browser,
22
+ ...globals.es2022,
23
+ },
24
+ parserOptions: {
25
+ project: tsconfigPath,
26
+ ecmaFeatures: { jsx: true },
27
+ },
28
+ },
29
+ plugins: {
30
+ ...pluginInstances,
31
+ "import-x": importXPlugin,
32
+ react: reactPlugin,
33
+ "react-hooks": reactHooksPlugin,
34
+ },
35
+ settings: {
36
+ react: { version: "detect" },
37
+ },
38
+ rules: {
39
+ ...bestPractices.rules,
40
+ ...errors.rules,
41
+ ...style.rules,
42
+ ...pluginRules,
43
+ ...typescriptRules.rules,
44
+ ...reactPlugin.configs.recommended.rules,
45
+ ...reactHooksPlugin.configs.recommended.rules,
46
+ "react/react-in-jsx-scope": "off",
47
+ "react/prop-types": "off",
48
+ ...importXRules,
49
+ },
50
+ });
51
+ }
52
+
53
+ export default buildReactPreset();
package/presets/ts.js ADDED
@@ -0,0 +1,43 @@
1
+ import prettierConfig from "eslint-config-prettier";
2
+ import importXPlugin from "eslint-plugin-import-x";
3
+ import globals from "globals";
4
+ import tseslint from "typescript-eslint";
5
+
6
+ import bestPractices from "../rules/best-practices.js";
7
+ import errors from "../rules/errors.js";
8
+ import { importXRules, pluginInstances, pluginRules } from "../rules/plugins.js";
9
+ import style from "../rules/style.js";
10
+ import typescriptRules from "../rules/typescript.js";
11
+
12
+ export function buildTsPreset(tsconfigPath = "./tsconfig.json") {
13
+ return tseslint.config(prettierConfig, ...tseslint.configs.recommendedTypeChecked, {
14
+ files: ["**/*.{ts,tsx}"],
15
+ languageOptions: {
16
+ ecmaVersion: "latest",
17
+ sourceType: "module",
18
+ globals: {
19
+ ...globals.browser,
20
+ ...globals.es2022,
21
+ ...globals.node,
22
+ },
23
+ parserOptions: {
24
+ project: tsconfigPath,
25
+ ecmaFeatures: { jsx: true },
26
+ },
27
+ },
28
+ plugins: {
29
+ ...pluginInstances,
30
+ "import-x": importXPlugin,
31
+ },
32
+ rules: {
33
+ ...bestPractices.rules,
34
+ ...errors.rules,
35
+ ...style.rules,
36
+ ...pluginRules,
37
+ ...typescriptRules.rules,
38
+ ...importXRules,
39
+ },
40
+ });
41
+ }
42
+
43
+ export default buildTsPreset();
@@ -0,0 +1,13 @@
1
+ import vitestPlugin from "@vitest/eslint-plugin";
2
+
3
+ export default [
4
+ {
5
+ files: ["**/*.test.{js,ts,jsx,tsx}", "**/*.spec.{js,ts,jsx,tsx}", "**/__tests__/**/*.{js,ts,jsx,tsx}"],
6
+ plugins: {
7
+ vitest: vitestPlugin,
8
+ },
9
+ rules: {
10
+ ...vitestPlugin.configs.recommended.rules,
11
+ },
12
+ },
13
+ ];
@@ -1,9 +1,10 @@
1
- module.exports = {
1
+ export default {
2
2
  rules: {
3
3
  camelcase: ["error", { properties: "never" }],
4
- eqeqeq: "error",
4
+ eqeqeq: ["error", "always", { null: "ignore" }],
5
5
  "new-cap": ["error", { capIsNew: false }],
6
6
  "no-array-constructor": "error",
7
+ "no-var": "error",
7
8
  "no-console": ["error", { allow: ["error"] }],
8
9
  "no-else-return": ["error", { allowElseIf: false }],
9
10
  "no-extend-native": "error",
package/rules/errors.js CHANGED
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  rules: {
3
3
  "array-callback-return": ["error", { checkForEach: true }],
4
4
  "no-await-in-loop": "error",
@@ -6,9 +6,11 @@ module.exports = {
6
6
  "no-constructor-return": "error",
7
7
  "no-promise-executor-return": "error",
8
8
  "no-self-compare": "error",
9
+ "no-shadow-restricted-names": ["error", { reportGlobalThis: true }],
9
10
  "no-template-curly-in-string": "error",
10
11
  "no-unmodified-loop-condition": "error",
11
12
  "no-unreachable-loop": "error",
13
+ "no-unused-expressions": ["error", { ignoreDirectives: true }],
12
14
  "no-unused-private-class-members": "error",
13
15
  "no-use-before-define": [
14
16
  "error",
package/rules/plugins.js CHANGED
@@ -1,47 +1,57 @@
1
- module.exports = {
2
- plugins: ["simple-import-sort", "import", "unused-imports"],
3
- rules: {
4
- "import/first": "error",
5
- "import/newline-after-import": "error",
6
- "import/no-duplicates": "error",
7
- "import/no-unresolved": "error",
8
- "import/no-webpack-loader-syntax": "error",
9
- "prettier/prettier": [
10
- "error",
11
- {
12
- arrowParens: "always",
13
- bracketSameLine: false,
14
- bracketSpacing: true,
15
- semi: true,
16
- experimentalTernaries: false,
17
- singleQuote: false,
18
- jsxSingleQuote: false,
19
- quoteProps: "as-needed",
20
- trailingComma: "es5",
21
- singleAttributePerLine: true,
22
- htmlWhitespaceSensitivity: "css",
23
- vueIndentScriptAndStyle: true,
24
- proseWrap: "preserve",
25
- insertPragma: false,
26
- printWidth: 120,
27
- requirePragma: false,
28
- tabWidth: 4,
29
- useTabs: true,
30
- embeddedLanguageFormatting: "auto",
31
- endOfLine: "lf",
32
- },
33
- ],
34
- "simple-import-sort/exports": "error",
35
- "simple-import-sort/imports": "error",
36
- "unused-imports/no-unused-imports": "error",
37
- "unused-imports/no-unused-vars": [
38
- "warn",
39
- {
40
- vars: "all",
41
- varsIgnorePattern: "^_",
42
- args: "after-used",
43
- argsIgnorePattern: "^_",
44
- },
45
- ],
46
- },
1
+ import prettierPlugin from "eslint-plugin-prettier";
2
+ import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
3
+ import unusedImportsPlugin from "eslint-plugin-unused-imports";
4
+
5
+ export const pluginInstances = {
6
+ prettier: prettierPlugin,
7
+ "simple-import-sort": simpleImportSortPlugin,
8
+ "unused-imports": unusedImportsPlugin,
9
+ };
10
+
11
+ export const pluginRules = {
12
+ "prettier/prettier": [
13
+ "error",
14
+ {
15
+ arrowParens: "always",
16
+ bracketSameLine: false,
17
+ bracketSpacing: true,
18
+ semi: true,
19
+ experimentalTernaries: false,
20
+ singleQuote: false,
21
+ jsxSingleQuote: false,
22
+ quoteProps: "as-needed",
23
+ trailingComma: "es5",
24
+ singleAttributePerLine: true,
25
+ htmlWhitespaceSensitivity: "css",
26
+ vueIndentScriptAndStyle: true,
27
+ proseWrap: "preserve",
28
+ insertPragma: false,
29
+ printWidth: 120,
30
+ requirePragma: false,
31
+ tabWidth: 4,
32
+ useTabs: true,
33
+ embeddedLanguageFormatting: "auto",
34
+ endOfLine: "lf",
35
+ },
36
+ ],
37
+ "simple-import-sort/exports": "error",
38
+ "simple-import-sort/imports": "error",
39
+ "unused-imports/no-unused-imports": "error",
40
+ "no-unused-vars": "off",
41
+ "unused-imports/no-unused-vars": [
42
+ "warn",
43
+ {
44
+ vars: "all",
45
+ varsIgnorePattern: "^_",
46
+ args: "after-used",
47
+ argsIgnorePattern: "^_",
48
+ },
49
+ ],
50
+ };
51
+
52
+ export const importXRules = {
53
+ "import-x/first": "error",
54
+ "import-x/newline-after-import": "error",
55
+ "import-x/no-duplicates": "error",
56
+ "import-x/no-webpack-loader-syntax": "error",
47
57
  };
package/rules/style.js CHANGED
@@ -1,10 +1,7 @@
1
- module.exports = {
1
+ export default {
2
2
  rules: {
3
3
  curly: "error",
4
4
  "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
5
- "padding-line-between-statements": [
6
- "error",
7
- { blankLine: "always", prev: "*", next: "return" },
8
- ],
5
+ "padding-line-between-statements": ["error", { blankLine: "always", prev: "*", next: "return" }],
9
6
  },
10
7
  };
@@ -1,12 +1,10 @@
1
- module.exports = {
2
- plugins: ["@typescript-eslint"],
1
+ export default {
3
2
  rules: {
4
3
  "@typescript-eslint/member-ordering": [
5
4
  "error",
6
5
  {
7
6
  default: [
8
7
  "signature",
9
-
10
8
  "private-decorated-field",
11
9
  "private-instance-field",
12
10
  "private-static-field",
@@ -18,11 +16,9 @@ module.exports = {
18
16
  "public-decorated-field",
19
17
  "public-instance-field",
20
18
  "public-static-field",
21
-
22
19
  "private-constructor",
23
20
  "protected-constructor",
24
21
  "public-constructor",
25
-
26
22
  "private-decorated-method",
27
23
  "private-instance-method",
28
24
  "private-static-method",
@@ -37,24 +33,24 @@ module.exports = {
37
33
  ],
38
34
  },
39
35
  ],
40
- "@typescript-eslint/no-confusing-non-null-assertion": ["error"],
36
+ "@typescript-eslint/no-confusing-non-null-assertion": "error",
41
37
  "@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
42
- "@typescript-eslint/no-explicit-any": ["warn"],
43
- "@typescript-eslint/no-extra-non-null-assertion": ["error"],
44
- "@typescript-eslint/no-floating-promises": ["error"],
45
- "@typescript-eslint/no-non-null-asserted-optional-chain": ["error"],
46
- "@typescript-eslint/no-non-null-assertion": ["error"],
47
- "@typescript-eslint/no-require-imports": ["error"],
48
- "@typescript-eslint/no-unnecessary-boolean-literal-compare": ["error"],
49
- "@typescript-eslint/no-unnecessary-condition": ["error"],
38
+ "@typescript-eslint/no-explicit-any": "warn",
39
+ "@typescript-eslint/no-extra-non-null-assertion": "error",
40
+ "@typescript-eslint/no-floating-promises": "error",
41
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
42
+ "@typescript-eslint/no-non-null-assertion": "error",
43
+ "@typescript-eslint/no-require-imports": "error",
44
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
45
+ "@typescript-eslint/no-unnecessary-condition": "error",
50
46
  "@typescript-eslint/no-unused-vars": "off",
51
- "@typescript-eslint/no-useless-constructor": ["error"],
52
- "@typescript-eslint/prefer-for-of": ["error"],
53
- "@typescript-eslint/prefer-nullish-coalescing": ["error"],
54
- "@typescript-eslint/prefer-readonly": ["error"],
47
+ "@typescript-eslint/no-useless-constructor": "error",
48
+ "@typescript-eslint/prefer-for-of": "error",
49
+ "@typescript-eslint/prefer-nullish-coalescing": "error",
50
+ "@typescript-eslint/prefer-readonly": "error",
55
51
  "@typescript-eslint/promise-function-async": ["error", { checkArrowFunctions: false }],
56
- "@typescript-eslint/require-await": ["warn"],
57
- "@typescript-eslint/switch-exhaustiveness-check": ["error"],
52
+ "@typescript-eslint/require-await": "warn",
53
+ "@typescript-eslint/switch-exhaustiveness-check": "error",
58
54
  "@typescript-eslint/explicit-member-accessibility": [
59
55
  "error",
60
56
  {
@@ -64,5 +60,6 @@ module.exports = {
64
60
  },
65
61
  },
66
62
  ],
63
+ "@typescript-eslint/explicit-module-boundary-types": "error",
67
64
  },
68
65
  };
package/.eslintrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": ["./index.js"]
3
- }
@@ -1,22 +0,0 @@
1
- name: 'Publish in NPM'
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- npm-publish:
10
- runs-on: ubuntu-latest
11
- environment: NPM
12
- steps:
13
- - uses: actions/checkout@v3
14
- - uses: actions/setup-node@v3
15
- with:
16
- node-version: '16'
17
- registry-url: 'https://registry.npmjs.org/'
18
- - run: npm install
19
- - run: npm run build --if-present
20
- - uses: JS-DevTools/npm-publish@v1
21
- with:
22
- token: ${{ secrets.TOKEN_NPM }}
package/Readme.md DELETED
@@ -1,76 +0,0 @@
1
- # Streamlined ESLint Configuration for JS/TS Projects
2
-
3
- This document outlines the steps to integrate my ESLint setup into your JavaScript or TypeScript projects. It's a personal collection of configurations and plugins aimed at fostering a consistent coding style and catching common errors.
4
-
5
- ## Quick Start Guide
6
-
7
- ### Step 1: Installation
8
-
9
- Add the configuration package to your development dependencies:
10
-
11
- ```bash
12
- npm install -D @kembec/eslint-config
13
- ```
14
-
15
- ### Step 2: Configure ESLint
16
-
17
- Modify your ESLint configuration file to use this package. The setup varies slightly depending on whether you're working with plain JavaScript or TypeScript.
18
-
19
- - **For JavaScript Projects**: In your `.eslintrc` (which could be a `.json`, `.js`, or `.ts` file), include the following:
20
-
21
- ```json
22
- {
23
- "extends": ["@kembec/eslint-config"]
24
- // Include Jest
25
- "extends": ["@kembec/eslint-config/jest"]
26
- }
27
- ```
28
-
29
- - **For TypeScript Projects**: To incorporate TypeScript-specific rules and configure the parser options, use this setup:
30
-
31
- ```json
32
- {
33
- "extends": ["@kembec/eslint-config/typescript"],
34
- // Include Jest
35
- "extends": ["@kembec/eslint-config/typescript/jest"]
36
- "overrides": [
37
- {
38
- "files": ["*.ts", "*.tsx"],
39
- "parserOptions": {
40
- "project": ["./tsconfig.json"]
41
- }
42
- }
43
- ]
44
- }
45
- ```
46
-
47
- ## Included Plugins
48
-
49
- The configuration incorporates a carefully selected set of ESLint plugins to assist with various code quality and style concerns:
50
-
51
- - `eslint-plugin-import`: Manages and validates import statements.
52
- - `eslint-plugin-jest`: Provides linting rules for Jest tests.
53
- - `eslint-plugin-prettier`: Integrates Prettier formatting into ESLint.
54
- - `eslint-plugin-simple-import-sort`: Automatically sorts import statements.
55
- - `eslint-plugin-unused-imports`: Helps in removing unused imports.
56
- - `@typescript-eslint/eslint-plugin`: Adds TypeScript-specific linting rules.
57
- - `@typescript-eslint/parser`: Allows ESLint to parse TypeScript code.
58
-
59
- These plugins are intended to help maintain a clean codebase and promote coding best practices.
60
-
61
- ## Usage
62
-
63
- Integrate linting into your workflow with these npm scripts:
64
-
65
- ```json
66
- "scripts": {
67
- "lint": "eslint .",
68
- "lint:fix": "eslint --fix ."
69
- }
70
- ```
71
-
72
- Use `npm run lint` to identify issues or `npm run lint:fix` to fix many issues automatically.
73
-
74
- ## License
75
-
76
- This project is licensed under the [AGPL-3.0](https://opensource.org/licenses/AGPL-3.0). Its use, modification, and distribution are allowed under the terms of this license.
package/jest/index.js DELETED
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- extends: ["../index.js"],
3
- overrides: [
4
- {
5
- files: ["*.test.js"],
6
- plugins: ["jest"],
7
- extends: ["plugin:jest/recommended"],
8
- rules: {},
9
- },
10
- ],
11
- };
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- rules: {
3
- "no-var": "error",
4
- "no-unused-vars": ["error", { vars: "all", args: "after-used", ignoreRestSiblings: true }],
5
- "no-use-before-define": ["error", { functions: true, classes: true, variables: true }],
6
- },
7
- };
@@ -1,28 +0,0 @@
1
- module.exports = {
2
- parser: "@typescript-eslint/parser",
3
- parserOptions: {
4
- ecmaFeatures: {
5
- jsx: true,
6
- },
7
- ecmaVersion: 12,
8
- sourceType: "module",
9
- },
10
- extends: ["../index.js"],
11
- overrides: [
12
- {
13
- files: ["*.ts", "*.tsx"],
14
- extends: [
15
- "plugin:@typescript-eslint/recommended",
16
- "plugin:@typescript-eslint/recommended-requiring-type-checking",
17
- "plugin:import/typescript",
18
- ...["../rules/typescript"].map(require.resolve),
19
- ],
20
- },
21
- {
22
- files: ["*.ts"],
23
- rules: {
24
- "@typescript-eslint/explicit-module-boundary-types": ["error"],
25
- },
26
- },
27
- ],
28
- };
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- extends: ["../index.js"],
3
- overrides: [
4
- {
5
- files: ["*.test.ts"],
6
- plugins: ["jest"],
7
- extends: ["plugin:jest/recommended"],
8
- rules: {},
9
- },
10
- ],
11
- };