@hearthsim/eslint-config-typescript-react 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,29 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*'
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - uses: actions/setup-node@v1
14
+ with:
15
+ node-version: 12
16
+ - run: yarn install --frozen-lockfile
17
+
18
+ publish-npm:
19
+ needs: build
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - uses: actions/setup-node@v1
24
+ with:
25
+ node-version: 12
26
+ registry-url: https://registry.npmjs.org/
27
+ - run: yarn publish --access public
28
+ env:
29
+ NODE_AUTH_TOKEN: ${{secrets.NPM_HEARTHSIM_TOKEN}}
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2022, Benedict Etzel
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # @hearthsim/eslint-config-typescript-react
2
+
3
+ This repository contains the HearthSim common ESLint configuration with Typescript and React support.
4
+
5
+ For a version **without** React support use [@HearthSim/eslint-config-typescript](https://github.com/HearthSim/eslint-config-typescript) instead.
6
+
7
+ ## Setup
8
+
9
+ 1. Install
10
+
11
+ ```bash
12
+ $ yarn add -D eslint @hearthsim/eslint-config-typescript-react
13
+ ```
14
+
15
+ 2. Install ESLint plugins
16
+ Plugins are resolved relative to the final project and must thus installed explicitly as part of the project:
17
+
18
+ ```bash
19
+ $ yarn add -D \
20
+ @typescript-eslint/eslint-plugin@5.4.0 \
21
+ eslint-plugin-import@2.25.3 \
22
+ eslint-plugin-jest@25.2.4 \
23
+ eslint-plugin-react@7.27.1 \
24
+ eslint-plugin-react-hooks@4.3.0
25
+ ```
26
+
27
+ 3. Configure ESLint:
28
+
29
+ Create or update your`.eslintrc.js`:
30
+ ```js
31
+ module.exports = {
32
+ root: true,
33
+ extends: ["@hearthsim/eslint-config-typescript-react"],
34
+ env: {
35
+ browser: true,
36
+ },
37
+ };
38
+ ```
39
+
40
+ 4. Add the scripts to your `package.json`:
41
+
42
+ ```json
43
+ {
44
+ "scripts": {
45
+ "lint:eslint": "eslint --cache ./"
46
+ }
47
+ }
48
+
49
+ ```
50
+
51
+ ## Philosophy
52
+
53
+ ### Zero tolerance for Errors false positives
54
+ If a rule is not able to handle the ways we legitimately use it, it needs to be downgraded to a warning.
55
+ Errors are reserved for critical issues that can directly introduce security risks, break the application or lead to severe performance penalties.
package/index.js ADDED
@@ -0,0 +1,34 @@
1
+ module.exports = {
2
+ plugins: ["@typescript-eslint", "import"],
3
+ extends: [
4
+ "@hearthsim/eslint-config-typescript",
5
+ "plugin:react/recommended",
6
+ "plugin:react-hooks/recommended",
7
+ ],
8
+ settings: {
9
+ react: {
10
+ version: "detect",
11
+ },
12
+ },
13
+ rules: {
14
+ // we don't use this
15
+ "react/display-name": "off",
16
+ // not great, but otherwise we get false positives with <Trans> (localization)
17
+ "react/jsx-key": "warn",
18
+ // The following rule is very sensible, enforcing noopener is critical. However, we're usually okay with
19
+ // exposing the referrer. Unfortunately it can't handle styled-components anchors, and cannot always detect
20
+ // internal links.
21
+ "react/jsx-no-target-blank": [
22
+ "warn",
23
+ {
24
+ allowReferrer: true,
25
+ },
26
+ ],
27
+ // our build chain can handle literals
28
+ "react/no-unescaped-entities": "off",
29
+ // doesn't work reliably with typescript (`FC<Props>` vs. `{} :Props`)
30
+ "react/prop-types": "off",
31
+ // we shouldn't usually have to worry about this
32
+ "react/react-in-jsx-scope": "off",
33
+ },
34
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@hearthsim/eslint-config-typescript-react",
3
+ "version": "1.0.0",
4
+ "description": "HearthSim's presets for ESLint, with Typescript and React support.",
5
+ "repository": "git@github.com:HearthSim/eslint-config-typescript-react.git",
6
+ "author": "Benedict Etzel <benedict@hearthsim.net>",
7
+ "homepage": "https://github.com/HearthSim/eslint-config-typescript-react#readme",
8
+ "license": "ISC",
9
+ "scripts": {
10
+ "format": "prettier --write *.js"
11
+ },
12
+ "peerDependencies": {
13
+ "@typescript-eslint/eslint-plugin": "5.4.0",
14
+ "eslint": "^6.8.0 || ^7.2.0 || ^8.0.0",
15
+ "eslint-plugin-import": "^2.25.3",
16
+ "eslint-plugin-jest": "^25.2.4",
17
+ "eslint-plugin-react": "^7.27.1",
18
+ "eslint-plugin-react-hooks": "^4.3.0",
19
+ "prettier": ">=2.0.0",
20
+ "typescript": ">=2.8.0"
21
+ },
22
+ "dependencies": {
23
+ "@hearthsim/eslint-config-typescript": "^2.0.0",
24
+ "@typescript-eslint/parser": "5.4.0",
25
+ "eslint-config-prettier": "^8.3.0"
26
+ },
27
+ "devDependencies": {
28
+ "eslint": "^8.0.0",
29
+ "prettier": "^2.2.1",
30
+ "typescript": "^4.0.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "prettier": {
36
+ "useTabs": true,
37
+ "trailingComma": "all"
38
+ }
39
+ }