@open-turo/eslint-config-react 1.0.1 → 1.1.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 @@
1
+ * @open-turo/node
@@ -2,6 +2,8 @@ version: 2
2
2
  updates:
3
3
  - package-ecosystem: npm
4
4
  directory: /
5
+ reviewers:
6
+ - "open-turo/node"
5
7
  schedule:
6
8
  interval: weekly
7
9
  commit-message:
@@ -8,12 +8,12 @@ jobs:
8
8
  name: Lint
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
- - uses: actions/checkout@v2
11
+ - uses: actions/checkout@v3
12
12
  with:
13
13
  fetch-depth: 0
14
- - uses: wagoid/commitlint-github-action@v4
15
- - uses: actions/setup-python@v2
16
- - uses: KeisukeYamashita/setup-release@v1.0.2
17
- with:
18
- repository: rhysd/actionlint
19
- - uses: pre-commit/action@v2.0.0
14
+ - name: Download actionlint
15
+ run: |
16
+ mkdir -p "$HOME/bin"
17
+ bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) latest "$HOME/bin"
18
+ echo "${HOME}/bin" >> "$GITHUB_PATH"
19
+ - uses: open-turo/action-pre-commit@v1
@@ -7,7 +7,7 @@ repos:
7
7
  - id: end-of-file-fixer
8
8
  - id: trailing-whitespace
9
9
  - repo: https://github.com/pre-commit/mirrors-prettier
10
- rev: v2.5.1
10
+ rev: v2.7.1
11
11
  hooks:
12
12
  - id: prettier
13
13
  stages: [commit]
package/README.md CHANGED
@@ -1,6 +1,17 @@
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.
4
15
 
5
16
  ## Usage
6
17
 
@@ -10,12 +21,34 @@ Install the package and all of its peer dependencies:
10
21
  npx install-peerdeps --dev @open-turo/eslint-config-react
11
22
  ```
12
23
 
13
- Then in your `.eslintrc` file add:
24
+ Then in your `.eslintrc` file extend from one of the two configurations included in this package:
25
+
26
+ 1. The default, based on our existing front-end repositories
27
+ 2. The "extended", which adds more react-related plugins. We intend to transition to this one as default over time
28
+
29
+ ### Default config
30
+
31
+ The default config of this repo is the recommended version for nour existing front-end projects.
32
+
33
+ To use this config, just add to your `.eslintrc` the following:
34
+
35
+ ```
36
+ "extends": "@open-turo/eslint-config-typescript"
37
+ ```
38
+
39
+ ### Extended config (extended react-related rules)
40
+
41
+ We also provide an alternative `extended` preset, which adds more react-related plugins.
42
+ We intend to transition to this one as default over time; and we encourage you to use it for new projects.
43
+
44
+ If you want to use this `extended` configuration, you can import it by instead adding the following to your `.eslintrc`:
14
45
 
15
46
  ```
16
- "extends": "@open-turo/eslint-config-react"
47
+ "extends": "@open-turo/eslint-config-typescript/extended"
17
48
  ```
18
49
 
50
+ Simply notice the `/extended` suffix, which points to the `extended.js` file in this repository.
51
+
19
52
  ## Development
20
53
 
21
54
  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.1"
38
+ "version": "1.1.0"
37
39
  }