@qlik/eslint-config 0.0.15 → 0.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.
package/README.md CHANGED
@@ -1,67 +1,110 @@
1
1
  # @qlik/eslint-config
2
2
 
3
- ESlint config for pure javascript/typescript environments. Based on airbnb-base/prettier config with some modifications.
3
+ Qlik's ESlint config for pure javascript/typescript environments. Based on airbnb-base/prettier config with some modifications.
4
4
 
5
5
  ## usage
6
6
 
7
+ These configs assumes that you are using typescript. It is still possible to write .js files and get linting on those.
8
+
7
9
  Simplest approach is to add one of the following field in `package.json`:
8
10
 
9
- For a pure javascript environment use:
11
+ For a pure environment with no specific frameworks use:
12
+
13
+ ```json
14
+ "eslintConfig": {
15
+ "root": true,
16
+ "parserOptions": {
17
+ "project": "path/to/tsconfig.json"
18
+ },
19
+ "extends": [
20
+ "@qlik/eslint-config"
21
+ ]
22
+ },
23
+ ```
24
+
25
+ Using react:
26
+
27
+ ```json
28
+ "eslintConfig": {
29
+ "root": true,
30
+ "parserOptions": {
31
+ "project": "path/to/tsconfig.json"
32
+ },
33
+ "extends": [
34
+ "@qlik/eslint-config/react"
35
+ ]
36
+ },
37
+ ```
38
+
39
+ Using svelte:
10
40
 
11
41
  ```json
12
42
  "eslintConfig": {
13
- "extends": [
14
- "@qlik/eslint-config"
15
- ],
16
- "root": true
43
+ "root": true,
44
+ "parserOptions": {
45
+ "project": "path/to/tsconfig.json"
17
46
  },
47
+ "extends": [
48
+ "@qlik/eslint-config/svelte"
49
+ ]
50
+ },
18
51
  ```
19
52
 
20
- To enable linting on typescript (.ts, .tsx):
53
+ Using react AND svelte (rare occasion):
21
54
 
22
55
  ```json
23
56
  "eslintConfig": {
24
- "extends": [
25
- "@qlik/eslint-config/typescript"
26
- ],
27
- "root": true
57
+ "root": true,
58
+ "parserOptions": {
59
+ "project": "path/to/tsconfig.json"
28
60
  },
61
+ "extends": [
62
+ "@qlik/eslint-config/react-svelte"
63
+ ]
64
+ },
29
65
  ```
30
66
 
31
67
  For a node environment with commonjs modules use:
32
68
 
33
69
  ```json
34
70
  "eslintConfig": {
35
- "extends": [
36
- "@qlik/eslint-config/node"
37
- ],
38
- "root": true
71
+ "root": true,
72
+ "parserOptions": {
73
+ "project": "path/to/tsconfig.json"
39
74
  },
75
+ "extends": [
76
+ "@qlik/eslint-config/node"
77
+ ]
78
+ },
40
79
  ```
41
80
 
42
81
  For a node environment with ES modules use:
43
82
 
44
83
  ```json
45
84
  "eslintConfig": {
46
- "extends": [
47
- "@qlik/eslint-config/node-esm"
48
- ],
49
- "root": true
85
+ "root": true,
86
+ "parserOptions": {
87
+ "project": "path/to/tsconfig.json"
50
88
  },
89
+ "extends": [
90
+ "@qlik/eslint-config/esm"
91
+ ]
92
+ },
51
93
  ```
52
94
 
53
95
  Additional configs that can be used in conjunction with the above:
54
96
 
55
97
  ```json
56
98
  "eslintConfig": {
57
- "extends": [
58
- "...",
59
- "@qlik/eslint-config/jest" // adds linting on jest test and config files
60
- // OR
61
- "@qlik/eslint-config/vitest" // adds linting on vitest test and config files
62
- // AND/OR
63
- "@qlik/eslint-config/playwright" // adds linting on playwright test and config files
64
- ],
65
- "root": true
99
+ "root": true,
100
+ "parserOptions": {
101
+ "project": "path/to/tsconfig.json"
66
102
  },
103
+ "extends": [
104
+ "...",
105
+ "@qlik/eslint-config/vitest", // adds linting on vitest test and config files
106
+ // AND/OR
107
+ "@qlik/eslint-config/playwright" // adds linting on playwright test and config files
108
+ ]
109
+ },
67
110
  ```
package/esm.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ extends: ["./node"],
3
+ rules: {
4
+ "import/extensions": ["error", "ignorePackages"],
5
+ },
6
+ };
package/index.js CHANGED
@@ -1,14 +1,22 @@
1
1
  module.exports = {
2
- extends: ["airbnb-base", "@qlik/eslint-config-base", "prettier"],
3
- rules: {
4
- // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
5
- "import/prefer-default-export": "off",
6
- // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
7
- "import/no-extraneous-dependencies": [
8
- "off",
9
- {
10
- devDependencies: ["**/jest-setup.js", "**/webpack.config.js", "**/svelte.config.js"],
11
- },
12
- ],
2
+ extends: [
3
+ "eslint:recommended",
4
+ "plugin:@typescript-eslint/recommended",
5
+ "plugin:@typescript-eslint/recommended-requiring-type-checking",
6
+ "airbnb-base",
7
+ "airbnb-typescript",
8
+ "./mods/airbnb-base",
9
+ "prettier",
10
+ ],
11
+ env: {
12
+ browser: true,
13
+ es2020: true,
14
+ node: true,
15
+ },
16
+ plugins: ["@typescript-eslint"],
17
+ parser: "@typescript-eslint/parser",
18
+ parserOptions: {
19
+ sourceType: "module",
20
+ ecmaVersion: 2020,
13
21
  },
14
22
  };
@@ -0,0 +1,74 @@
1
+ module.exports = {
2
+ rules: {
3
+ // modifies airbnb default rules
4
+ "no-undef": "off", // typescript handles these checks
5
+ "no-underscore-dangle": "off",
6
+ "class-methods-use-this": "off",
7
+ "no-plusplus": "off",
8
+ "prefer-destructuring": ["error", { object: true, array: false }],
9
+ "guard-for-in": "off",
10
+
11
+ // allows for..in and for..of
12
+ "no-restricted-syntax": [
13
+ "error",
14
+ // {
15
+ // selector: "ForInStatement",
16
+ // message:
17
+ // "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.",
18
+ // },
19
+ // {
20
+ // selector: "ForOfStatement",
21
+ // message:
22
+ // "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.",
23
+ // },
24
+ {
25
+ selector: "LabeledStatement",
26
+ message: "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
27
+ },
28
+ {
29
+ selector: "WithStatement",
30
+ message: "`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
31
+ },
32
+ ],
33
+
34
+ // modifies airbnb ts default rules
35
+ "lines-between-class-members": "off",
36
+ "@typescript-eslint/lines-between-class-members": "off",
37
+
38
+ // discouraged https://palantir.github.io/tslint/rules/no-use-before-declare/
39
+ "no-use-before-define": "off",
40
+ "@typescript-eslint/no-use-before-define": "off",
41
+
42
+ "dot-notation": "off",
43
+ "@typescript-eslint/dot-notation": "off",
44
+
45
+ "@typescript-eslint/prefer-ts-expect-error": "error",
46
+ "@typescript-eslint/no-misused-promises": [
47
+ "error",
48
+ {
49
+ checksConditionals: false,
50
+ },
51
+ ],
52
+
53
+ // no-unsafe-* does not work good
54
+ "@typescript-eslint/no-unsafe-call": "off",
55
+ "@typescript-eslint/no-unsafe-member-access": "off",
56
+ "@typescript-eslint/no-unsafe-return": "off",
57
+ "@typescript-eslint/no-unsafe-argument": "off",
58
+ "@typescript-eslint/no-unsafe-assignment": "off",
59
+
60
+ // import plugin
61
+ "import/prefer-default-export": "off",
62
+ "import/no-extraneous-dependencies": [
63
+ "off",
64
+ {
65
+ devDependencies: [
66
+ "**/webpack.config.js",
67
+ "**/svelte.config.js",
68
+ "**/playwright.config.ts",
69
+ "**/playwright.config.js",
70
+ ],
71
+ },
72
+ ],
73
+ },
74
+ };
package/mods/airbnb.js ADDED
@@ -0,0 +1,17 @@
1
+ module.exports = {
2
+ extends: ["./airbnb-base.js"],
3
+ rules: {
4
+ // modifies airbnb rules for react
5
+ "react/jsx-props-no-spreading": "off",
6
+ "react/jsx-uses-react": "off",
7
+ "react/react-in-jsx-scope": "off",
8
+ "react/forbid-prop-types": "off",
9
+ "react/function-component-definition": [
10
+ 2,
11
+ {
12
+ namedComponents: "arrow-function",
13
+ unnamedComponents: "arrow-function",
14
+ },
15
+ ],
16
+ },
17
+ };
package/mods/svelte.js ADDED
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ extends: ["plugin:svelte/recommended", "plugin:svelte/prettier"],
3
+ parserOptions: {
4
+ extraFileExtensions: [".svelte"],
5
+ },
6
+ overrides: [
7
+ {
8
+ files: ["*.svelte"],
9
+ parser: "svelte-eslint-parser",
10
+ parserOptions: {
11
+ parser: "@typescript-eslint/parser",
12
+ },
13
+ rules: {
14
+ "no-undef-init": "off",
15
+ "no-unused-vars": "off",
16
+ "@typescript-eslint/no-unused-vars": "off",
17
+ "import/no-mutable-exports": "off",
18
+ },
19
+ },
20
+ ],
21
+ };
package/node.js CHANGED
@@ -1,9 +1,9 @@
1
1
  module.exports = {
2
+ extends: ["./index"],
2
3
  env: {
3
4
  node: true,
4
5
  browser: false,
5
6
  },
6
- extends: ["airbnb-base", "@qlik/eslint-config-base", "prettier"],
7
7
  rules: {
8
8
  "no-console": "off",
9
9
  },
package/package.json CHANGED
@@ -1,30 +1,44 @@
1
1
  {
2
2
  "name": "@qlik/eslint-config",
3
- "version": "0.0.15",
4
- "description": "Qlik's ESLint config",
3
+ "version": "0.1.0",
4
+ "description": "Qlik's ESLint config for typescript",
5
5
  "repository": "git@github.com:qlik-oss/dev-tools-js.git",
6
6
  "license": "ISC",
7
7
  "main": "index.js",
8
8
  "files": [
9
+ "mods",
10
+ "index.js",
9
11
  "node.js",
10
- "node-esm.js",
11
- "jest.js",
12
+ "esm.js",
13
+ "react.js",
14
+ "svelte.js",
15
+ "vitest.js",
12
16
  "playwright.js",
13
- "typescript.js",
14
- "vitest.js"
17
+ "react-svelte.js"
15
18
  ],
16
19
  "prettier": "@qlik/prettier-config",
17
20
  "eslintConfig": {
18
- "extends": "./node.js"
21
+ "env": {
22
+ "es6": true,
23
+ "node": true
24
+ },
25
+ "extends": "eslint:recommended"
19
26
  },
20
27
  "dependencies": {
21
28
  "@typescript-eslint/eslint-plugin": "5.59.5",
22
29
  "@typescript-eslint/parser": "5.59.5",
30
+ "eslint-config-airbnb": "19.0.4",
23
31
  "eslint-config-airbnb-base": "15.0.0",
24
32
  "eslint-config-airbnb-typescript": "17.0.0",
25
33
  "eslint-config-prettier": "8.8.0",
26
34
  "eslint-plugin-import": "2.27.5",
27
- "@qlik/eslint-config-base": "0.0.15"
35
+ "eslint-plugin-jsx-a11y": "6.7.1",
36
+ "eslint-plugin-playwright": "0.12.0",
37
+ "eslint-plugin-react": "7.32.2",
38
+ "eslint-plugin-react-hooks": "4.6.0",
39
+ "eslint-plugin-svelte": "2.28.0",
40
+ "eslint-plugin-vitest": "0.2.2",
41
+ "svelte-eslint-parser": "0.28.0"
28
42
  },
29
43
  "devDependencies": {
30
44
  "eslint": "8.40.0",
@@ -35,6 +49,7 @@
35
49
  "eslint": "*"
36
50
  },
37
51
  "optionalDependencies": {
52
+ "svelte": "^3.59.1",
38
53
  "typescript": "^5.0.4"
39
54
  },
40
55
  "engines": {
package/playwright.js CHANGED
@@ -1,3 +1,11 @@
1
- const playwright = require("@qlik/eslint-config-base/playwright");
2
-
3
- module.exports = playwright;
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: ["**/test/integration/**", "**/test/e2e/**"],
5
+ extends: ["plugin:playwright/playwright-test"],
6
+ rules: {
7
+ "import/no-extraneous-dependencies": "off",
8
+ },
9
+ },
10
+ ],
11
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ["./react", "./mods/svelte"],
3
+ };
package/react.js ADDED
@@ -0,0 +1,22 @@
1
+ module.exports = {
2
+ extends: [
3
+ "eslint:recommended",
4
+ "plugin:@typescript-eslint/recommended",
5
+ "plugin:@typescript-eslint/recommended-requiring-type-checking",
6
+ "airbnb",
7
+ "airbnb-typescript",
8
+ "./mods/airbnb",
9
+ "prettier",
10
+ ],
11
+ env: {
12
+ browser: true,
13
+ es2020: true,
14
+ node: true,
15
+ },
16
+ plugins: ["@typescript-eslint"],
17
+ parser: "@typescript-eslint/parser",
18
+ parserOptions: {
19
+ sourceType: "module",
20
+ ecmaVersion: 2020,
21
+ },
22
+ };
package/svelte.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ["./index", "./mods/svelte"],
3
+ };
package/vitest.js CHANGED
@@ -1,3 +1,12 @@
1
- const vitest = require("@qlik/eslint-config-base/vitest");
2
-
3
- module.exports = vitest;
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: ["**/__tests__/**", "**/*.{spec|test}.{jsx?,tsx?}"],
5
+ plugins: ["vitest"],
6
+ extends: ["plugin:vitest/recommended"],
7
+ rules: {
8
+ "import/no-extraneous-dependencies": "off",
9
+ },
10
+ },
11
+ ],
12
+ };
package/jest.js DELETED
@@ -1,3 +0,0 @@
1
- const jest = require("@qlik/eslint-config-base/jest");
2
-
3
- module.exports = jest;
package/node-esm.js DELETED
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- env: {
3
- node: true,
4
- browser: false,
5
- },
6
- extends: ["airbnb-base", "@qlik/eslint-config-base", "prettier"],
7
- rules: {
8
- "no-console": "off",
9
- "import/extensions": ["error", "ignorePackages"],
10
- },
11
- };
package/typescript.js DELETED
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- extends: ["./index.js"],
3
- overrides: [
4
- {
5
- files: ["**/*.ts", "**/*.tsx"],
6
- extends: ["airbnb-base", "airbnb-typescript/base", "@qlik/eslint-config-base/typescript", "prettier"],
7
- rules: {
8
- // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
9
- "import/prefer-default-export": "off",
10
- // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
11
- "import/no-extraneous-dependencies": [
12
- "off",
13
- {
14
- devDependencies: ["**/jest-setup.js", "**/webpack.config.js", "**/svelte.config.js"],
15
- },
16
- ],
17
- },
18
- },
19
- ],
20
- };