@rebilly/eslint-config 0.0.3

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,28 @@
1
+ # Rebilly shared eslint configs
2
+
3
+ These are the shared eslint configs for all Rebilly frontend projects.
4
+
5
+ Where possible, we should exclusively try to `extend` these configs, and
6
+ avoid adding overrides in our projects. This will keep the projects consistent and
7
+ reduce the difficulty when switching between projects.
8
+
9
+ ## Usage
10
+
11
+ 1. Install the package in the project: `pnpm add -D @rebilly/eslint-config@workspace:*`
12
+ 2. Extend the appropriate config in the project's `.eslintrc.js` file:
13
+
14
+ ```js
15
+ module.exports = {
16
+ root: true,
17
+ // Which config to extend depends on the project type, see below
18
+ extends: ["@rebilly/eslint-config/vue"],
19
+ };
20
+ ```
21
+
22
+ ## Configs
23
+
24
+ | Config | Extend | Description |
25
+ | ---------- | ------------------------------------- | -------------------------------------------------------------------------------------- |
26
+ | Base | `@rebilly/eslint-config` | Base config for all projects, containing generic Javascript and Prettier eslint rules. |
27
+ | Typescript | `@rebilly/eslint-config/typescript` | TypeScript projects. |
28
+ | Vue | `@rebilly/eslint-config/vue` | Vue projects written in TypeScript. |
package/index.js ADDED
@@ -0,0 +1,58 @@
1
+ const vitest = require('eslint-plugin-vitest');
2
+
3
+ module.exports = {
4
+ extends: ['eslint:recommended', 'plugin:cypress/recommended', 'prettier'],
5
+ env: {
6
+ es6: true,
7
+ },
8
+ parserOptions: {
9
+ ecmaVersion: 'latest',
10
+ },
11
+ rules: {
12
+ 'no-underscore-dangle': [
13
+ 'error',
14
+ { allow: ['_links', '_embedded', '_dev'] },
15
+ ],
16
+ 'prettier/prettier': 'error',
17
+ 'no-lonely-if': 'error',
18
+ 'no-implicit-coercion': 'error',
19
+ },
20
+ plugins: ['prettier', 'vitest'],
21
+ globals: {
22
+ // TODO: remove this and extend from vitest/recommended when there is time to fix the errors.
23
+ ...vitest.environments.env.globals,
24
+ },
25
+ overrides: [
26
+ {
27
+ // Config files are usually executed in the node environment, regardless of the project type
28
+ files: [
29
+ '.eslintrc.cjs',
30
+ '.eslintrc.js',
31
+ 'babel.config.js',
32
+ 'cypress.config.js',
33
+ 'vite.config.js',
34
+ ],
35
+ env: {
36
+ node: true,
37
+ },
38
+ },
39
+ {
40
+ files: ['*.spec.js', '*.spec.ts'],
41
+ globals: {
42
+ // We configure vite with globals: true, which adds this global variable
43
+ // https://vitest.dev/config/#globals
44
+ global: true,
45
+ },
46
+ },
47
+ ],
48
+ ignorePatterns: [
49
+ 'node_modules/',
50
+ 'dist/',
51
+ 'typings/',
52
+ 'coverage/',
53
+ 'public/static/',
54
+ '*.css',
55
+ '*.svg',
56
+ '*.min.js',
57
+ ],
58
+ };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@rebilly/eslint-config",
3
+ "description": "Shared ESLint config for Rebilly frontend projects",
4
+ "author": "Rebilly",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Rebilly/rebilly.git"
8
+ },
9
+ "main": "index.js",
10
+ "version": "0.0.3",
11
+ "scripts": {
12
+ "build": "echo 'Building ESLint config'"
13
+ },
14
+ "files": [
15
+ "index.js",
16
+ "typescript.js",
17
+ "vue.js"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "peerDependencies": {
23
+ "@typescript-eslint/eslint-plugin": "^7.17.0",
24
+ "@typescript-eslint/parser": "^7.14.1",
25
+ "@vue/eslint-config-typescript": "^14.5.0",
26
+ "eslint": "^8.57.1",
27
+ "eslint-plugin-cypress": "^3.5.0",
28
+ "eslint-plugin-vitest": "^0.5.4",
29
+ "eslint-plugin-vue": "^9.32.0",
30
+ "vue-eslint-parser": "^10.1.1"
31
+ },
32
+ "devDependencies": {
33
+ "@typescript-eslint/eslint-plugin": "^7.17.0",
34
+ "@typescript-eslint/parser": "^7.14.1",
35
+ "@vue/eslint-config-typescript": "^14.5.0",
36
+ "eslint": "^8.57.1",
37
+ "eslint-plugin-cypress": "^3.5.0",
38
+ "eslint-plugin-vitest": "^0.5.4",
39
+ "eslint-plugin-vue": "^9.32.0",
40
+ "prettier": "^3.1.0",
41
+ "vue-eslint-parser": "^10.1.1"
42
+ },
43
+ "engines": {
44
+ "node": ">=18.18"
45
+ }
46
+ }
package/typescript.js ADDED
@@ -0,0 +1,34 @@
1
+ module.exports = {
2
+ extends: ['plugin:@typescript-eslint/recommended', './index.js'],
3
+ parser: '@typescript-eslint/parser',
4
+ parserOptions: {
5
+ parser: '@typescript-eslint/parser',
6
+ ecmaVersion: 2022,
7
+ sourceType: 'module',
8
+ },
9
+ plugins: ['@typescript-eslint'],
10
+ rules: {
11
+ 'no-undef': 'off',
12
+ 'no-unused-vars': 'off',
13
+ '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
14
+ '@typescript-eslint/ban-ts-comment': [
15
+ 'error',
16
+ {
17
+ 'ts-ignore': true,
18
+ 'ts-expect-error': 'allow-with-description',
19
+ 'ts-nocheck': 'allow-with-description',
20
+ },
21
+ ],
22
+ '@typescript-eslint/consistent-type-imports': 'error',
23
+ },
24
+ overrides: [
25
+ {
26
+ files: ['*.ts'],
27
+ rules: {
28
+ // It is recommended to turn this rule off for typescript, as it does it's own checking:
29
+ // https://typescript-eslint.io/linting/troubleshooting#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
30
+ 'no-undef': 'off',
31
+ },
32
+ },
33
+ ],
34
+ };
package/vue.js ADDED
@@ -0,0 +1,46 @@
1
+ module.exports = {
2
+ env: {
3
+ 'vue/setup-compiler-macros': true,
4
+ browser: true,
5
+ },
6
+ extends: ['plugin:vue/vue3-recommended', './typescript.js'],
7
+ parser: 'vue-eslint-parser',
8
+ rules: {
9
+ 'vue/require-v-for-key': 'error',
10
+ 'vue/require-prop-types': 'error',
11
+ 'vue/component-tags-order': [
12
+ 'error',
13
+ {
14
+ order: ['script', 'template', 'style'],
15
+ },
16
+ ],
17
+ 'vue/multi-word-component-names': 'off',
18
+ // Force lang="ts" in script tags
19
+ 'vue/block-lang': [
20
+ 'error',
21
+ {
22
+ script: {
23
+ lang: 'ts',
24
+ },
25
+ },
26
+ ],
27
+ 'vue/component-api-style': ['error', ['script-setup']],
28
+ },
29
+ overrides: [
30
+ {
31
+ files: ['*.vue'],
32
+ rules: {
33
+ // It is recommended to turn this rule off for typescript, as it does it's own checking:
34
+ // https://typescript-eslint.io/linting/troubleshooting#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
35
+ 'no-undef': 'off',
36
+ },
37
+ },
38
+ {
39
+ files: ['*.spec.js', '*.spec.ts'],
40
+ rules: {
41
+ // This can throw erroneously in test files, and doesn't apply
42
+ 'vue/one-component-per-file': 'off',
43
+ },
44
+ },
45
+ ],
46
+ };