@castiron/eslint-config 0.0.1 → 1.0.0-beta.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.
Binary file
package/.yarnrc.yml ADDED
@@ -0,0 +1 @@
1
+ nodeLinker: node-modules
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
1
  # Changelog
2
2
 
3
3
  **All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org).**
4
+
5
+ ## 1.0.0-beta.0
6
+
7
+ - Upgrades eslint to v9
8
+ - Upgrades all eslint packages
9
+ - Removes prettier packages
10
+ - Splits eslint config into 4 flat configs: base, js, ts, and react
11
+ - Upgrades yarn to v4
12
+ - Upgrades node to v20
13
+ - Updates readme
package/README.md CHANGED
@@ -2,16 +2,79 @@
2
2
 
3
3
  An ESLint [Shareable Config](http://eslint.org/docs/developer-guide/shareable-configs) for CIC projects
4
4
 
5
- ## Install
5
+ ## 💿 Installation
6
6
 
7
7
  ```bash
8
- yarn add eslint-config-cic -D
8
+ yarn add @castiron/eslint-config -D
9
9
  ```
10
10
 
11
- Then add this to your `.eslintrc` file:
11
+ ## 📖 Usage
12
12
 
13
+ ### New Config (eslint.config.js)
14
+
15
+ For all the rules, add this to your `eslint.config.js` file:
16
+
17
+ ```js
18
+ // eslint.config.js
19
+ import cicConfig from "@castiron/eslint-config";
20
+
21
+ export default [...cicConfig];
22
+ ```
23
+
24
+ If you'd like to use only some of the rules, each config has a named export:
25
+
26
+ ```js
27
+ // Example: Vanilla js project with babel parser.
28
+ // eslint.config.js
29
+ import { baseConfig, jsConfig } from "@castiron/eslint-config";
30
+
31
+ export default [
32
+ {
33
+ parser: "@babel/eslint-parser",
34
+ parserOptions: {
35
+ sourceType: "module",
36
+ requireConfigFile: false,
37
+ babelOptions: {
38
+ plugins: [
39
+ "@babel/plugin-transform-react-jsx",
40
+ "@babel/plugin-proposal-class-properties",
41
+ ],
42
+ },
43
+ },
44
+ }
45
+ baseConfig,
46
+ jsConfig,
47
+ ];
13
48
  ```
49
+
50
+ ```js
51
+ // Example: Astro project without react.
52
+ // eslint.config.js
53
+ import { baseConfig, jsConfig, tsConfig } from "@castiron/eslint-config";
54
+ import eslintPluginAstro from "eslint-plugin-astro";
55
+
56
+ export default [
57
+ {
58
+ ignores: ["dist/", ".astro/"],
59
+ },
60
+ baseConfig,
61
+ jsConfig,
62
+ tsConfig,
63
+ ...eslintPluginAstro.configs.recommended,
64
+ ];
65
+ ```
66
+
67
+ ### package.json
68
+
69
+ Add lint and fix scripts to package.json:
70
+
71
+ ```json
72
+ // package.json
14
73
  {
15
- "extends": "cic"
74
+ "scripts": {
75
+ // ...,
76
+ "lint": "eslint .",
77
+ "fix": "eslint . --fix"
78
+ }
16
79
  }
17
80
  ```
@@ -0,0 +1,17 @@
1
+ import js from "@eslint/js";
2
+ import globals from "globals";
3
+
4
+ const jsConfig = {
5
+ files: ["**/*.{js,jsx,mjs,cjs}"],
6
+ languageOptions: {
7
+ globals: {
8
+ ...globals.browser,
9
+ ...globals.node,
10
+ }
11
+ },
12
+ rules: {
13
+ ...js.configs.recommended.rules,
14
+ },
15
+ }
16
+
17
+ export default jsConfig;
@@ -0,0 +1,25 @@
1
+ import reactHooks from "eslint-plugin-react-hooks";
2
+ import jsxA11y from "eslint-plugin-jsx-a11y";
3
+
4
+ const reactConfig = {
5
+ files: ["**/*.{jsx,tsx}"],
6
+ rules: {
7
+ ...reactHooks.configs.recommended.rules,
8
+ ...jsxA11y.configs.recommended.rules,
9
+ // React rules
10
+ "react-hooks/rules-of-hooks": ["warn"],
11
+ "react/react-in-jsx-scope": ["off"],
12
+ "react/display-name": ["off"],
13
+ },
14
+ plugins: {
15
+ "jsx-a11y": jsxA11y,
16
+ "react-hooks": reactHooks,
17
+ },
18
+ settings: {
19
+ react: {
20
+ version: "detect",
21
+ },
22
+ }
23
+ };
24
+
25
+ export default reactConfig;
@@ -0,0 +1,41 @@
1
+ import tsParser from "@typescript-eslint/parser";
2
+ import ts from "@typescript-eslint/eslint-plugin";
3
+ import globals from "globals";
4
+
5
+ const tsConfig = {
6
+ files: ["**/*.{ts,tsx}"],
7
+ languageOptions: {
8
+ parser: tsParser,
9
+ parserOptions: {
10
+ project: "./tsconfig.json",
11
+ },
12
+ // Any globals that we don't want to flag for no-undef can be added here
13
+ globals: {
14
+ ...globals.browser,
15
+ ...globals.node,
16
+ React: "false",
17
+ },
18
+ },
19
+ rules: {
20
+ // Typescript rules
21
+ "@typescript-eslint/no-unused-vars": [
22
+ "error",
23
+ {
24
+ varsIgnorePattern: "^_",
25
+ argsIgnorePattern: "^_",
26
+ destructuredArrayIgnorePattern: "^_",
27
+ ignoreRestSiblings: true,
28
+ caughtErrors: "none",
29
+ },
30
+ ],
31
+ "@typescript-eslint/ban-ts-comment": [
32
+ "error",
33
+ { "ts-expect-error": "allow-with-description" },
34
+ ],
35
+ },
36
+ plugins: {
37
+ "@typescript-eslint": ts,
38
+ },
39
+ };
40
+
41
+ export default tsConfig;
@@ -0,0 +1,65 @@
1
+ import ts from "@typescript-eslint/eslint-plugin";
2
+ import unusedImports from "eslint-plugin-unused-imports";
3
+ import globals from "globals";
4
+
5
+ const baseConfig = {
6
+ files: ["**/*.{js,jsx,ts,tsx}"],
7
+ languageOptions: {
8
+ globals: {
9
+ ...globals.browser,
10
+ ...globals.node,
11
+ }
12
+ },
13
+ rules: {
14
+ ...ts.configs.recommended.rules,
15
+ ...ts.configs["eslint-recommended"].rules,
16
+ "array-callback-return": 0,
17
+ "arrow-body-style": 0,
18
+ "global-require": 0,
19
+ "consistent-return": 0,
20
+ "prefer-template": 0,
21
+ "no-useless-constructor": 0,
22
+ quotes: 0,
23
+ "block-scoped-var": 0,
24
+ "comma-dangle": 0,
25
+ "comma-spacing": 2,
26
+ "generator-star-spacing": 0,
27
+ indent: 0,
28
+ "no-alert": 2,
29
+ "no-console": ["error", { allow: ["warn", "error", "info", "debug", "dir"] }],
30
+ "no-debugger": 2,
31
+ semi: 0,
32
+ "no-empty-pattern": 1,
33
+ "no-extra-semi": 0,
34
+ "no-unused-semi": 0,
35
+ "no-unused-vars": [
36
+ 0,
37
+ {
38
+ args: "after-used",
39
+ varsIgnorePattern: "PropTypes",
40
+ argsIgnorePattern: "[iI]gnored",
41
+ },
42
+ ],
43
+ "no-trailing-spaces": 2,
44
+ "no-multiple-empty-lines": 2,
45
+ "no-underscore-dangle": 0,
46
+ "max-len": [
47
+ "error",
48
+ {
49
+ ignoreComments: true,
50
+ ignoreStrings: true,
51
+ ignoreTemplateLiterals: true,
52
+ },
53
+ ],
54
+ "padded-blocks": 0,
55
+ "prefer-const": 2,
56
+ "space-before-function-paren": 0,
57
+ "spaced-comment": 2,
58
+ },
59
+ plugins: {
60
+ "unused-imports": unusedImports,
61
+ "@typescript-eslint": ts,
62
+ }
63
+ };
64
+
65
+ export default baseConfig;
package/index.js CHANGED
@@ -1,85 +1,15 @@
1
- module.exports = {
2
- root: true,
3
- parser: "@babel/eslint-parser",
4
- parserOptions: {
5
- sourceType: "module",
6
- requireConfigFile: false,
7
- babelOptions: {
8
- plugins: [
9
- "@babel/plugin-transform-react-jsx",
10
- "@babel/plugin-proposal-class-properties",
11
- ],
12
- },
13
- },
14
- env: {
15
- browser: true,
16
- },
17
- settings: {
18
- react: {
19
- version: "detect",
20
- },
21
- },
22
- rules: {
23
- "array-callback-return": 0,
24
- "arrow-body-style": 0,
25
- "global-require": 0,
26
- "consistent-return": 0,
27
- "prefer-template": 0,
28
- "no-useless-constructor": 0,
29
- "jsx-a11y/img-has-alt": 0,
30
- "jsx-a11y/no-onchange": 0,
31
- quotes: 0,
32
- // This rule doesn't work well with jsconfig
33
- "import/no-unresolved": 0,
34
- "jsx-quotes": 2,
35
- "jsx-a11y/media-has-caption": 1,
36
- "block-scoped-var": 0,
37
- "comma-dangle": 0,
38
- "comma-spacing": 2,
39
- "generator-star-spacing": 0,
40
- indent: 0,
41
- "no-alert": 2,
42
- "no-console": ["error", { allow: ["warn", "error", "info"] }],
43
- "no-debugger": 2,
44
- semi: 0,
45
- "no-empty-pattern": 1,
46
- "no-extra-semi": 0,
47
- "no-unused-semi": 0,
48
- "no-unused-vars": [
49
- 0,
50
- {
51
- args: "after-used",
52
- varsIgnorePattern: "PropTypes",
53
- argsIgnorePattern: "[iI]gnored",
54
- },
55
- ],
56
- "no-trailing-spaces": 2,
57
- "no-multiple-empty-lines": 2,
58
- "no-underscore-dangle": 0,
59
- "max-len": [
60
- "error",
61
- {
62
- ignoreComments: true,
63
- ignoreStrings: true,
64
- ignoreTemplateLiterals: true,
65
- },
66
- ],
67
- "padded-blocks": 0,
68
- "prefer-const": 2,
69
- "react-hooks/rules-of-hooks": "error",
70
- "react-hooks/exhaustive-deps": "warn",
71
- "react/react-in-jsx-scope": 0,
72
- "space-before-function-paren": 0,
73
- "spaced-comment": 2,
74
- "unused-imports/no-unused-imports": 2,
75
- },
76
- plugins: ["jsx-a11y", "react", "react-hooks", "unused-imports"],
77
- extends: [
78
- "standard",
79
- "plugin:jsx-a11y/recommended",
80
- "plugin:react/recommended",
81
- "plugin:prettier/recommended",
82
- "prettier/standard",
83
- "plugin:import/errors",
84
- ],
85
- };
1
+ import baseConfig from "./configs/configs-base.mjs";
2
+ import jsConfig from "./configs/config-js.mjs";
3
+ import tsConfig from "./configs/config-ts.mjs";
4
+ import reactConfig from "./configs/config-react.mjs";
5
+
6
+ // Export one big config (React/TS projects)
7
+ export default [
8
+ baseConfig,
9
+ jsConfig,
10
+ tsConfig,
11
+ reactConfig
12
+ ];
13
+
14
+ // Export configs separately for finer control over linting rules
15
+ export { baseConfig, jsConfig, tsConfig, reactConfig };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@castiron/eslint-config",
3
- "version": "0.0.1",
3
+ "version": "1.0.0-beta.0",
4
4
  "description": "General eslint configuration for Cast Iron Coding projects",
5
- "main": "index.js",
5
+ "main": "index.mjs",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/castiron/eslint-config-cic.git"
@@ -13,28 +13,37 @@
13
13
  "url": "https://github.com/castiron/eslint-config-cic/issues"
14
14
  },
15
15
  "homepage": "https://github.com/castiron/eslint-config-cic#readme",
16
+ "engines": {
17
+ "node": "20.x",
18
+ "yarn": "4.6.0"
19
+ },
16
20
  "scripts": {
17
- "npm:publish": "yarn publish --access public"
21
+ "npm:publish": "yarn publish --access public",
22
+ "lint": "eslint . --config index.mjs",
23
+ "fix": "eslint . --fix"
24
+ },
25
+ "devDependencies": {
26
+ "@typescript-eslint/eslint-plugin": "^8.26.0",
27
+ "@typescript-eslint/parser": "^8.26.0",
28
+ "eslint": "^9.21.0",
29
+ "eslint-plugin-import": "^2.31.0",
30
+ "eslint-plugin-jsx-a11y": "^6.10.2",
31
+ "eslint-plugin-react": "^7.37.4",
32
+ "eslint-plugin-react-hooks": "^5.2.0",
33
+ "eslint-plugin-unused-imports": "^4.1.4",
34
+ "globals": "^16.0.0",
35
+ "typescript": "^5.8.2"
18
36
  },
19
- "dependencies": {
20
- "@babel/core": "^7.13.10",
21
- "@babel/eslint-parser": "^7.12.1",
22
- "@babel/plugin-proposal-class-properties": "^7.12.13",
23
- "@babel/plugin-transform-react-jsx": "^7.12.13",
24
- "eslint": "^7.13.0",
25
- "eslint-config-prettier": "^7.2.0",
26
- "eslint-config-standard": "^16.0.2",
27
- "eslint-plugin-import": "^2.22.1",
28
- "eslint-plugin-jsx-a11y": "^6.4.1",
29
- "eslint-plugin-node": "^11.1.0",
30
- "eslint-plugin-prettier": "^3.1.4",
31
- "eslint-plugin-promise": "^4.2.1",
32
- "eslint-plugin-react": "^7.21.5",
33
- "eslint-plugin-react-hooks": "^4.2.0",
34
- "eslint-plugin-standard": "^4.1.0",
35
- "eslint-plugin-unused-imports": "^1.0.1",
36
- "prettier": "^2.1.2",
37
- "typescript": "^4.2.3"
37
+ "peerDependencies": {
38
+ "@typescript-eslint/eslint-plugin": ">= 8",
39
+ "@typescript-eslint/parser": ">= 8",
40
+ "eslint": ">= 9",
41
+ "eslint-plugin-import": ">= 2",
42
+ "eslint-plugin-jsx-a11y": ">= 6",
43
+ "eslint-plugin-react": ">= 7",
44
+ "eslint-plugin-react-hooks": ">= 5",
45
+ "eslint-plugin-unused-imports": ">= 4",
46
+ "typescript": ">= 5"
38
47
  },
39
- "devDependencies": {}
48
+ "packageManager": "yarn@4.7.0"
40
49
  }