eslint-config-makeable 8.1.0 → 9.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.
@@ -1,11 +1,11 @@
1
1
  {
2
- "editor.formatOnSave": true,
2
+ "editor.formatOnSave": false,
3
3
  "[javascript]": {
4
4
  "editor.formatOnSave": true
5
5
  },
6
6
  "eslint.alwaysShowStatus": true,
7
7
  "editor.codeActionsOnSave": {
8
- "source.fixAll": true
8
+ "source.fixAll": "explicit"
9
9
  },
10
10
  "prettier.enable": false
11
- }
11
+ }
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Makeable esLint-setup
2
2
 
3
- Enable Makeable's NodeJS formatting and linting for Typescript projects
3
+ Enable Makeable's NodeJS formatting and linting for Typescript and Vue projects
4
4
 
5
5
 
6
6
  ## Prerequisites
@@ -13,7 +13,7 @@ https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
13
13
 
14
14
  ## Installation
15
15
 
16
- ```cd``` into the directory containing your Typescript package.json and run the following command:
16
+ ```cd``` into the directory containing your Typescript or Vue package.json and run the following command:
17
17
 
18
18
  ```npm i eslint-config-makeable -D```
19
19
 
@@ -21,22 +21,61 @@ Copy the following scripts into your package.json-file:
21
21
 
22
22
  ```
23
23
  "scripts": {
24
- "lint": "eslint --ext .ts,.js,.vue src/",
25
- "lint:fix": "eslint --fix --ext .ts,.js,.vue src/"
24
+ "lint": "eslint .",
25
+ "lint:fix": "eslint --fix ."
26
26
  }
27
27
  ```
28
28
 
29
- Copy the following setting into your package.json-file:
29
+ In the project root, create a file called eslint.config.mjs and copy the following content into it:
30
30
 
31
31
  ```
32
- "eslintConfig": {
33
- "extends": [
34
- "eslint-config-makeable"
35
- ]
36
- },
32
+ import makeable from 'eslint-config-makeable';
33
+
34
+ export default [
35
+ {
36
+ ignores: [
37
+ '**/lib/**',
38
+ '**/dist/**',
39
+ 'eslint.config.mjs'
40
+ ],
41
+ },
42
+ ...makeable,
43
+ {
44
+ rules: {
45
+ /* Custom rules here */
46
+ },
47
+ },
48
+ ];
49
+ ```
50
+
51
+ If the project is a Vue project with unplugin-auto-import enabled, add the following to your eslint.config.mjs:
52
+
53
+ ```
54
+ import { FlatCompat } from '@eslint/eslintrc'
55
+ import makeable from 'eslint-config-makeable';
56
+
57
+ const compat = new FlatCompat()
58
+
59
+ export default [
60
+ {
61
+ ignores: [
62
+ '**/lib/**',
63
+ '**/dist/**',
64
+ 'eslint.config.mjs',
65
+ ],
66
+ },
67
+ ...makeable,
68
+ ...compat.extends('./.eslintrc-auto-import.json'),
69
+ {
70
+ rules: {
71
+ /* Custom rules here */
72
+ },
73
+ },
74
+ ];
37
75
  ```
38
76
 
39
77
  Copy the .vscode folder from the newly installed node-module to the root of your directory to avoid auto-formatting conflicts with other services like prettier-extension, typescript and vscode auto-formatting.
78
+ The auto-formatting after save only works if the .vscode folder is in the root of the directory that is open in vscode/cursor - Even if the linting is supposed to run in a subdirectory, the .vscode folder must be in the root of the directory that is open in vscode/cursor.
40
79
 
41
80
  ## Usage
42
81
 
package/index.mjs ADDED
@@ -0,0 +1,153 @@
1
+ import { FlatCompat } from '@eslint/eslintrc';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import globals from 'globals';
5
+ import pluginVue from 'eslint-plugin-vue';
6
+ import tseslint from 'typescript-eslint';
7
+ import vueParser from 'vue-eslint-parser';
8
+ import eslintConfigPrettier from 'eslint-config-prettier';
9
+ import eslintPluginPrettier from 'eslint-plugin-prettier';
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ const compat = new FlatCompat({
15
+ baseDirectory: __dirname,
16
+ });
17
+
18
+ const tsTemplateParser = {
19
+ parse: (code, options) => tseslint.parser.parseForESLint(code, options).ast,
20
+ };
21
+
22
+ export default [
23
+ ...compat.extends('airbnb-base'),
24
+ ...pluginVue.configs['flat/recommended'],
25
+ eslintConfigPrettier,
26
+ {
27
+ languageOptions: {
28
+ globals: {
29
+ ...globals.browser,
30
+ ...globals.node,
31
+ // Vue 3 compiler macros
32
+ defineProps: 'readonly',
33
+ defineEmits: 'readonly',
34
+ defineExpose: 'readonly',
35
+ withDefaults: 'readonly',
36
+ },
37
+ parserOptions: {
38
+ ecmaVersion: 'latest',
39
+ sourceType: 'module',
40
+ },
41
+ },
42
+ plugins: {
43
+ prettier: eslintPluginPrettier,
44
+ },
45
+ rules: {
46
+ 'prettier/prettier': [
47
+ 2,
48
+ {
49
+ trailingComma: 'es5',
50
+ printWidth: 210,
51
+ tabWidth: 4,
52
+ singleQuote: true,
53
+ semi: true,
54
+ bracketSpacing: true,
55
+ arrowParens: 'always',
56
+ },
57
+ ],
58
+ 'no-console': 0,
59
+ 'no-empty': 0,
60
+ indent: 0,
61
+ 'comma-dangle': 0,
62
+ 'import/prefer-default-export': 0,
63
+ 'import/no-unresolved': 0,
64
+ radix: 0,
65
+ 'no-alert': 0,
66
+ 'max-len': 0,
67
+ 'no-await-in-loop': 0,
68
+ 'no-use-before-define': 0,
69
+ 'no-restricted-syntax': 0,
70
+ 'no-underscore-dangle': 0,
71
+ 'no-plusplus': 0,
72
+ 'prefer-destructuring': 0,
73
+ 'no-param-reassign': 0,
74
+ 'import/extensions': 0,
75
+ 'consistent-return': 0,
76
+ 'arrow-body-style': 0,
77
+ 'class-methods-use-this': 0,
78
+ 'no-undef': 0,
79
+ 'no-void': 0,
80
+ 'no-continue': 0,
81
+ 'no-promise-executor-return': 0,
82
+ 'spaced-comment': 1,
83
+ 'no-case-declarations': 1,
84
+ 'import/no-extraneous-dependencies': [
85
+ 2,
86
+ {
87
+ devDependencies: true,
88
+ optionalDependencies: true,
89
+ peerDependencies: true,
90
+ },
91
+ ],
92
+ 'no-multiple-empty-lines': 1,
93
+ 'import/newline-after-import': 1,
94
+ 'import/first': 1,
95
+ camelcase: 1,
96
+ 'prefer-const': 1,
97
+ 'import/no-dynamic-require': 1,
98
+ 'guard-for-in': 1,
99
+ 'vue/valid-template-root': 1,
100
+ 'vue/no-reserved-component-names': 1,
101
+ 'vue/multi-word-component-names': 0,
102
+ 'vue/singleline-html-element-content-newline': 0,
103
+ 'vue/html-indent': 0,
104
+ 'vue/max-attributes-per-line': 0,
105
+ 'vue/html-self-closing': 0,
106
+ 'vue/no-v-model-argument': 0,
107
+ 'vue/valid-v-model': 0,
108
+ 'vue/no-mutating-props': 0
109
+ },
110
+ },
111
+
112
+ {
113
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
114
+ languageOptions: {
115
+ parser: tseslint.parser,
116
+ },
117
+ plugins: {
118
+ '@typescript-eslint': tseslint.plugin,
119
+ },
120
+ rules: {
121
+ 'no-unused-vars': 0,
122
+ '@typescript-eslint/no-unused-vars': [
123
+ 1,
124
+ {
125
+ ignoreRestSiblings: true,
126
+ argsIgnorePattern: 'res|next|^err',
127
+ caughtErrors: 'none',
128
+ },
129
+ ],
130
+ },
131
+ },
132
+
133
+ {
134
+ files: ["*.vue", "**/*.vue"],
135
+ languageOptions: {
136
+ parser: vueParser,
137
+ parserOptions: {
138
+ parser: {
139
+ js: 'espree',
140
+ ts: tseslint.parser,
141
+ tsx: tseslint.parser,
142
+ '<template>': tsTemplateParser,
143
+ },
144
+ ecmaVersion: 'latest',
145
+ sourceType: 'module',
146
+ }
147
+ },
148
+ rules: {
149
+ '@typescript-eslint/no-unused-vars': 0,
150
+ 'no-unused-vars': 0
151
+ }
152
+ },
153
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-makeable",
3
- "version": "8.1.0",
3
+ "version": "9.1.0",
4
4
  "description": "ESlint config for Makeable's Typescript projects",
5
5
  "keywords": [
6
6
  "javascript",
@@ -11,26 +11,30 @@
11
11
  "config",
12
12
  "prettier"
13
13
  ],
14
- "main": "index.js",
14
+ "main": "index.mjs",
15
+ "exports": {
16
+ ".": "./index.mjs"
17
+ },
18
+ "type": "module",
15
19
  "author": "Lasse Borgen <lasse@makeable.dk>",
16
20
  "dependencies": {
17
- "@typescript-eslint/eslint-plugin": "^5.59.6",
18
- "@typescript-eslint/parser": "^5.59.6",
19
- "eslint": "^7.0.0",
20
- "eslint-config-airbnb": "^19.0.0",
21
- "eslint-config-prettier": "^4.2.0",
22
- "eslint-plugin-import": "^2.26.0",
23
- "eslint-plugin-jsx-a11y": "^6.6.0",
24
- "eslint-plugin-prettier": "^3.0.1",
25
- "eslint-plugin-react": "^7.13.0",
26
- "eslint-plugin-vue": "^9.17.0",
27
- "prettier": "^1.18.0"
21
+ "@eslint/eslintrc": "^3.3.1",
22
+ "eslint": "^9.39.1",
23
+ "eslint-config-airbnb-base": "^15.0.0",
24
+ "eslint-config-prettier": "^10.1.8",
25
+ "eslint-plugin-import": "^2.32.0",
26
+ "eslint-plugin-prettier": "^5.5.4",
27
+ "eslint-plugin-vue": "^10.6.2",
28
+ "globals": "^16.2.0",
29
+ "prettier": "^3.7.4",
30
+ "typescript-eslint": "^8.33.1",
31
+ "vue-eslint-parser": "^10.2.0"
28
32
  },
29
33
  "peerDependencies": {
30
34
  "typescript": "*"
31
35
  },
32
36
  "scripts": {
33
- "lint": "eslint --ext .ts,.js,.vue src/",
34
- "lint:fix": "eslint --fix --ext .ts,.js,.vue src/"
37
+ "lint": "eslint src/",
38
+ "lint:fix": "eslint --fix src/"
35
39
  }
36
- }
40
+ }
package/.eslintrc.js DELETED
@@ -1,85 +0,0 @@
1
- module.exports = {
2
- "globals": {
3
- "defineProps": "readonly",
4
- "defineEmits": "readonly",
5
- "defineExpose": "readonly",
6
- "withDefaults": "readonly"
7
- },
8
- "extends": ["airbnb", "prettier", 'plugin:vue/vue3-recommended'],
9
- "plugins": ["prettier"],
10
- "parserOptions": {
11
- "parser": "@typescript-eslint/parser",
12
- "ecmaVersion": 2018,
13
- "sourceType": "module"
14
- },
15
- "env": {
16
- "browser": true,
17
- "node": true
18
- },
19
- "rules": {
20
- "prettier/prettier": [
21
- 2,
22
- {
23
- "trailingComma": "es5",
24
- "printWidth": 210,
25
- "tabWidth": 4,
26
- "singleQuote": true,
27
- "semi": true,
28
- "bracketSpacing": true,
29
- "arrowParens": "always"
30
- }
31
- ],
32
- "no-console": 0,
33
- "no-empty": 0,
34
- "indent": 0,
35
- "comma-dangle": 0,
36
- "import/prefer-default-export": 0,
37
- "import/no-unresolved": 0,
38
- "radix": 0,
39
- "no-alert": 0,
40
- "max-len": 0,
41
- "no-await-in-loop": 0,
42
- "no-use-before-define": 0,
43
- "no-restricted-syntax": 0,
44
- "no-underscore-dangle": 0,
45
- "no-plusplus": 0,
46
- "prefer-destructuring": 0,
47
- "no-param-reassign": 0,
48
- "import/extensions": 0,
49
- "spaced-comment": 1,
50
- "no-case-declarations": 1,
51
- "import/no-extraneous-dependencies": [
52
- 2,
53
- {
54
- "devDependencies": true,
55
- "optionalDependencies": true,
56
- "peerDependencies": true
57
- }
58
- ],
59
- "no-unused-vars": [
60
- 1,
61
- {
62
- "ignoreRestSiblings": true,
63
- "argsIgnorePattern": 'res|next|^err',
64
- },
65
- ],
66
- "consistent-return": 1,
67
- "no-multiple-empty-lines": 1,
68
- "import/newline-after-import": 1,
69
- "import/first": 1,
70
- "camelcase": 1,
71
- "prefer-const": 1,
72
- "import/no-dynamic-require": 1,
73
- "guard-for-in": 1,
74
- "vue/valid-template-root": 1,
75
- "arrow-body-style": 1,
76
- "vue/no-reserved-component-names": 1,
77
- "vue/multi-word-component-names": 0,
78
- "vue/singleline-html-element-content-newline": 0,
79
- "vue/html-indent": 0,
80
- "vue/max-attributes-per-line": 0,
81
- "vue/html-self-closing": 0,
82
- "vue/no-v-model-argument": 0,
83
- "vue/valid-v-model": 0,
84
- }
85
- }
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- const eslintrc = require('./.eslintrc');
2
-
3
- module.exports = eslintrc;