@open-turo/eslint-config-react 1.0.2 → 1.1.1

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.
@@ -8,7 +8,8 @@ jobs:
8
8
  name: Lint
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
- - uses: actions/checkout@v3
11
+ - name: Checkout
12
+ uses: actions/checkout@v3
12
13
  with:
13
14
  fetch-depth: 0
14
15
  - name: Download actionlint
@@ -9,10 +9,11 @@ jobs:
9
9
  release:
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - uses: actions/checkout@v2
12
+ - name: Checkout
13
+ uses: actions/checkout@v3
13
14
  with:
14
15
  fetch-depth: 0
15
- - name: Semantic Release
16
+ - name: Semantic release
16
17
  id: release
17
18
  uses: cycjimmy/semantic-release-action@v2
18
19
  with:
package/README.md CHANGED
@@ -1,6 +1,26 @@
1
1
  # `@open-turo/eslint-config-react`
2
2
 
3
- Turo eslint configuration for react. The config expects that Typescript is being used.
3
+ Turo eslint configuration for react. The config expects that Typescript is being used as it extends
4
+ `eslint-config-typescript`.
5
+
6
+ ## Relevant notes
7
+
8
+ The `eslint` configurations in this repo extend `@open-turo/eslint-config-typescript/legacy`; as it is the base TS
9
+ eslint config that supports our existing front-end codebase.
10
+
11
+ However, if you are creating a new React project and you think you would benefit from having the configurations in this
12
+ repository extend the default `@open-turo/eslint-config-typescript` config instead, please raise an issue and/or feel
13
+ free to create a PR to add a new default that extends it, and rename the current configurations to `legacy` and
14
+ `legacy-extended` respectively. We are not doing that for now to reduce maintenance burden, as it would be unused.
15
+
16
+ [![Release](https://img.shields.io/github/v/release/open-turo/eslint-config-react)](https://github.com/open-turo/eslint-config-react/releases/)
17
+ [![Tests pass/fail](https://img.shields.io/github/workflow/status/open-turo/eslint-config-react/CI)](https://github.com/open-turo/eslint-config-react/actions/)
18
+ [![License](https://img.shields.io/github/license/open-turo/eslint-config-react)](./LICENSE)
19
+ [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](https://github.com/dwyl/esta/issues)
20
+ ![CI](https://github.com/open-turo/eslint-config-react/actions/workflows/release.yaml/badge.svg)
21
+ [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
22
+ [![Conventional commits](https://img.shields.io/badge/conventional%20commits-1.0.2-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
23
+ [![Join us!](https://img.shields.io/badge/Turo-Join%20us%21-593CFB.svg)](https://turo.com/jobs)
4
24
 
5
25
  ## Usage
6
26
 
@@ -10,12 +30,34 @@ Install the package and all of its peer dependencies:
10
30
  npx install-peerdeps --dev @open-turo/eslint-config-react
11
31
  ```
12
32
 
13
- Then in your `.eslintrc` file add:
33
+ Then in your `.eslintrc` file extend from one of the two configurations included in this package:
34
+
35
+ 1. The default, based on our existing front-end repositories
36
+ 2. The "extended", which adds more react-related plugins. We intend to transition to this one as default over time
37
+
38
+ ### Default config
39
+
40
+ The default config of this repo is the recommended version for nour existing front-end projects.
41
+
42
+ To use this config, just add to your `.eslintrc` the following:
14
43
 
15
44
  ```
16
- "extends": "@open-turo/eslint-config-react"
45
+ "extends": "@open-turo/eslint-config-typescript"
17
46
  ```
18
47
 
48
+ ### Extended config (extended react-related rules)
49
+
50
+ We also provide an alternative `extended` preset, which adds more react-related plugins.
51
+ We intend to transition to this one as default over time; and we encourage you to use it for new projects.
52
+
53
+ If you want to use this `extended` configuration, you can import it by instead adding the following to your `.eslintrc`:
54
+
55
+ ```
56
+ "extends": "@open-turo/eslint-config-typescript/extended"
57
+ ```
58
+
59
+ Simply notice the `/extended` suffix, which points to the `extended.js` file in this repository.
60
+
19
61
  ## Development
20
62
 
21
63
  Install [pre-commit](https://pre-commit.com/) and the commit hooks:
package/extended.js ADDED
@@ -0,0 +1,43 @@
1
+ module.exports = {
2
+ root: true,
3
+ plugins: ["react", "react-hooks", "jsx-a11y"],
4
+ extends: [
5
+ "./index.js",
6
+ "plugin:react/recommended",
7
+ "plugin:react-hooks/recommended",
8
+ "plugin:jsx-a11y/recommended",
9
+ ],
10
+ parserOptions: {
11
+ ecmaFeatures: {
12
+ jsx: true,
13
+ },
14
+ },
15
+ rules: {
16
+ "jsx-a11y/anchor-is-valid": [
17
+ "warn",
18
+ {
19
+ specialLink: ["to"],
20
+ },
21
+ ],
22
+ // don't force .jsx extension
23
+ "react/jsx-filename-extension": "off",
24
+ // In TS you must use the Fragment syntax instead of the shorthand
25
+ "react/jsx-fragments": "off",
26
+ // This allows props to be spread in JSX
27
+ "react/jsx-props-no-spreading": "off",
28
+ // ensure props are alphabetical
29
+ "react/jsx-sort-props": "error",
30
+ // We don't need default props on TS components
31
+ "react/require-default-props": "off",
32
+ "react/sort-prop-types": "error",
33
+ // State initialization can be in the constructor or via class fields
34
+ "react/state-in-constructor": "off",
35
+ // This allows static properties to be placed within the class declaration
36
+ "react/static-property-placement": "off",
37
+ },
38
+ settings: {
39
+ react: {
40
+ version: "detect",
41
+ },
42
+ },
43
+ };
package/index.js CHANGED
@@ -1,46 +1,22 @@
1
1
  module.exports = {
2
- parser: "@typescript-eslint/parser",
3
- plugins: ["react", "react-hooks", "jsx-a11y"],
4
- extends: [
5
- "plugin:react/recommended",
6
- "plugin:react-hooks/recommended",
7
- "plugin:jsx-a11y/recommended",
8
- ],
9
- parserOptions: {
10
- ecmaVersion: 2022,
11
- sourceType: "module",
12
- ecmaFeatures: {
13
- jsx: true,
14
- },
2
+ root: true,
3
+ env: {
4
+ browser: true,
15
5
  },
6
+ ignorePatterns: ["babel.config.js"],
7
+ extends: ["@open-turo/eslint-config-typescript/legacy"],
16
8
  rules: {
17
- rules: {
18
- "jsx-a11y/anchor-is-valid": [
19
- "warn",
20
- {
21
- specialLink: ["to"],
22
- },
23
- ],
24
- // don't force .jsx extension
25
- "react/jsx-filename-extension": "off",
26
- // In TS you must use the Fragment syntax instead of the shorthand
27
- "react/jsx-fragments": "off",
28
- // This allows props to be spread in JSX
29
- "react/jsx-props-no-spreading": "off",
30
- // ensure props are alphabetical
31
- "react/jsx-sort-props": "error",
32
- // We don't need default props on TS components
33
- "react/require-default-props": "off",
34
- "react/sort-prop-types": "error",
35
- // State initialization can be in the constructor or via class fields
36
- "react/state-in-constructor": "off",
37
- // This allows static properties to be placed within the class declaration
38
- "react/static-property-placement": "off",
39
- },
40
- },
41
- settings: {
42
- react: {
43
- version: "detect",
44
- },
9
+ "node/no-unpublished-import": [
10
+ "error",
11
+ {
12
+ allowModules: [
13
+ "@jest/globals",
14
+ "@testing-library/dom",
15
+ "@testing-library/react",
16
+ "@testing-library/user-event",
17
+ "nock",
18
+ ],
19
+ },
20
+ ],
45
21
  },
46
22
  };
package/package.json CHANGED
@@ -4,10 +4,11 @@
4
4
  "devDependencies": {
5
5
  "@commitlint/cli": "^17.0.0",
6
6
  "@open-turo/commitlint-config-conventional": "^1.0.2",
7
+ "@open-turo/eslint-config-typescript": "2.0.0",
7
8
  "@semantic-release/git": "^10.0.1",
8
9
  "@typescript-eslint/eslint-plugin": "^5.20.0",
9
10
  "@typescript-eslint/parser": "^5.20.0",
10
- "eslint": "^8.16.0",
11
+ "eslint": "^8.28.0",
11
12
  "eslint-plugin-jsx-a11y": "^6.5.1",
12
13
  "eslint-plugin-react": "^7.29.4",
13
14
  "eslint-plugin-react-hooks": "^4.4.0",
@@ -22,6 +23,7 @@
22
23
  "main": "index.js",
23
24
  "name": "@open-turo/eslint-config-react",
24
25
  "peerDependencies": {
26
+ "@open-turo/eslint-config-typescript": "2.0.0",
25
27
  "@typescript-eslint/eslint-plugin": "^5.20.0",
26
28
  "@typescript-eslint/parser": "^5.20.0",
27
29
  "eslint": ">=8.16.0",
@@ -33,5 +35,5 @@
33
35
  "access": "public"
34
36
  },
35
37
  "repository": "https://github.com/open-turo/eslint-config-react",
36
- "version": "1.0.2"
38
+ "version": "1.1.1"
37
39
  }