@hubspot/eslint-config-ui-extensions 0.7.2

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.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @hubspot/eslint-config-ui-extensions
2
+
3
+ [eslint shareable configs](https://eslint.org/docs/latest/extend/shareable-configs) for building UI Extensions on HubSpot with React.
4
+
5
+ ## Installation
6
+
7
+ You'll first need to install [ESLint](https://eslint.org/) and alongside this package:
8
+
9
+ ```sh
10
+ npm i --save-dev eslint @hubspot/eslint-config-ui-extensions
11
+ ```
12
+
13
+
14
+ ## Usage
15
+
16
+ Create an .eslintrc.js file in the root of your project:
17
+
18
+ ```js
19
+ module.exports = {
20
+ extends: "@hubspot/ui-extensions",
21
+ ignorePatterns: ["node_modules", "dist"],
22
+ };
23
+ ```
24
+
25
+ For those using TypeScript, we'll likely expand this package to include a base setup in the near future, but in the meantime you can start here and follow these steps to get TS support:
26
+
27
+ - `npm i --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin`
28
+ - Adapt your lint script in package.json (if applicable) to make sure you're targeting your source files, perhaps something like `"lint": "npx eslint . --ext .ts,.tsx"`
29
+ - Update your eslintrc config:
30
+
31
+ ```diff
32
+ -extends: ['@hubspot/ui-extensions'],
33
+ +extends: ['@hubspot/ui-extensions', 'plugin:@typescript-eslint/recommended'],
34
+ +plugins: ['@typescript-eslint'],
35
+ ```
36
+
37
+ Running `npm run lint`, you should now see TypeScript-aware linting in your terminal output and it will likely automatically work inside your editor of choice as well (though some editors may require additional config steps).
38
+
39
+
40
+ ## Rules
41
+
42
+ This config extends the following configs, meaning you can customize the `rules` entry in your project-level config to include any rules from these packages:
43
+
44
+ - ['eslint:recommended'](https://eslint.org/docs/latest/rules/)
45
+ - ['plugin:react/recommended'](https://www.npmjs.com/package/eslint-plugin-react)
46
+ - ['plugin:react-hooks/recommended'](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks)
47
+ - ['prettier'](https://www.npmjs.com/package/eslint-config-prettier)
package/eslintrc.js ADDED
@@ -0,0 +1,12 @@
1
+ // eslint-disable-next-line no-undef
2
+ module.exports = {
3
+ root: true,
4
+ extends: [
5
+ 'eslint:recommended',
6
+ 'plugin:eslint-plugin/recommended',
7
+ 'plugin:node/recommended',
8
+ ],
9
+ env: {
10
+ node: true,
11
+ },
12
+ };
package/lib/index.js ADDED
@@ -0,0 +1,57 @@
1
+ const { languageOptions } = require('./runtime');
2
+
3
+ /**
4
+ * @see https://github.com/eslint/eslint/issues/3458
5
+ * @see https://www.npmjs.com/package/@rushstack/eslint-patch
6
+ */
7
+ require('@rushstack/eslint-patch/modern-module-resolution');
8
+
9
+ // eslint-disable-next-line no-undef
10
+ module.exports = {
11
+ env: {
12
+ browser: false,
13
+ es6: true,
14
+ worker: true,
15
+ },
16
+ plugins: ['react', 'react-hooks'],
17
+ extends: [
18
+ 'eslint:recommended',
19
+ 'plugin:react/recommended',
20
+ 'plugin:react-hooks/recommended',
21
+ 'prettier',
22
+ ],
23
+ globals: languageOptions.globals,
24
+ parserOptions: {
25
+ sourceType: languageOptions.sourceType,
26
+ ecmaVersion: languageOptions.ecmaVersion,
27
+ ecmaFeatures: {
28
+ jsx: true,
29
+ },
30
+ },
31
+ settings: {
32
+ react: {
33
+ version: 'detect',
34
+ },
35
+ },
36
+ rules: {
37
+ 'react/prop-types': [1, { skipUndeclared: true }],
38
+ 'no-restricted-globals': [
39
+ 'error',
40
+ {
41
+ name: 'importScripts',
42
+ message: 'function is undefined',
43
+ },
44
+ ],
45
+ },
46
+ overrides: [
47
+ {
48
+ env: {
49
+ node: true,
50
+ },
51
+ files: ['.eslintrc.{js,cjs}', 'eslint.config.js'],
52
+ parserOptions: {
53
+ sourceType: 'script',
54
+ },
55
+ },
56
+ ],
57
+ };
package/lib/runtime.js ADDED
@@ -0,0 +1,17 @@
1
+ const globals = require('globals');
2
+
3
+ // eslint-disable-next-line no-undef
4
+ module.exports = {
5
+ languageOptions: {
6
+ ecmaVersion: 6,
7
+ sourceType: 'module',
8
+ globals: {
9
+ ...globals.worker,
10
+ importScripts: 'off',
11
+ console: true,
12
+ React: true,
13
+ RemoteUI: true,
14
+ hubspot: true,
15
+ },
16
+ },
17
+ };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@hubspot/eslint-config-ui-extensions",
3
+ "version": "0.7.2",
4
+ "description": "eslint plugins for HubSpot React-based UI Extensions",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslintplugin",
8
+ "eslint-plugin"
9
+ ],
10
+ "main": "./lib/index.js",
11
+ "exports": "./lib/index.js",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "lint": "npm-run-all \"lint:*\"",
17
+ "lint:eslint-docs": "npm-run-all \"update:eslint-docs -- --check\"",
18
+ "lint:js": "eslint .",
19
+ "build": "echo 'no build command'",
20
+ "test": "echo 'mocha tests --recursive'",
21
+ "update:eslint-docs": "eslint-doc-generator"
22
+ },
23
+ "dependencies": {
24
+ "@rushstack/eslint-patch": "^1.3.3",
25
+ "eslint-config-prettier": "^9.0.0",
26
+ "eslint-plugin-react": "^7.33.1",
27
+ "eslint-plugin-react-hooks": "^4.6.0",
28
+ "globals": "^13.21.0"
29
+ },
30
+ "devDependencies": {
31
+ "eslint": "^8.19.0",
32
+ "eslint-doc-generator": "^1.0.0",
33
+ "eslint-plugin-eslint-plugin": "^5.0.0",
34
+ "eslint-plugin-node": "^11.1.0",
35
+ "npm-run-all": "^4.1.5"
36
+ },
37
+ "engines": {
38
+ "node": "^16.0.0 || >= 18.0.0"
39
+ },
40
+ "peerDependencies": {
41
+ "eslint": ">=8"
42
+ },
43
+ "peerDependenciesMeta": {
44
+ "typescript": {
45
+ "optional": true
46
+ }
47
+ },
48
+ "license": "MIT",
49
+ "gitHead": "7d2ae57e8f02e9b63468aa3881002d39078962e0"
50
+ }