@bitfactory/eslint-config 1.1.4 → 1.2.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 CHANGED
@@ -1,21 +1,25 @@
1
1
  # @bitfactory/eslint-config
2
2
 
3
- <p>
4
- <a href="https://www.npmjs.com/package/@bitfactory/eslint-config"><img src="https://img.shields.io/npm/v/@bitfactory/eslint-config.svg?sanitize=true" alt="Version"></a>
3
+ <p align="center">
4
+ <img src="https://img.shields.io/badge/release-1.2.x-orange?style=for-the-badge" alt="Release">
5
+ <img src="https://img.shields.io/badge/eslint-%5E7.x-8080F2?style=for-the-badge" alt="ESLint">
6
+ <a href="https://www.npmjs.com/package/@bitfactory/eslint-config"><img src="https://img.shields.io/npm/v/@bitfactory/eslint-config.svg?style=for-the-badge" alt="NPM version"></a>
5
7
  </p>
6
8
 
7
9
  This is a shareable config for [ESLint](https://eslint.org). All the rules and configurations are already set. Rules can be overridden if needed.
8
10
 
9
- - [Installing](#installing)
11
+ - [@bitfactory/eslint-config](#bitfactoryeslint-config)
12
+ - [:package: Installing](#package-installing)
10
13
  - [Vue.js projects](#vuejs-projects)
11
14
  - [TypeScript projects](#typescript-projects)
12
15
  - [Vue.js, TypeScript and regular JavaScript together](#vuejs-typescript-and-regular-javascript-together)
13
- - [CLI usage](#cli-usage)
14
- - [Editor / IDE integration](#editor--ide-integration)
15
- - [PhpStorm](#phpstorm)
16
+ - [:rocket: CLI usage](#rocket-cli-usage)
17
+ - [:pencil2: Editor / IDE integration](#pencil2-editor--ide-integration)
16
18
  - [Visual Studio Code](#visual-studio-code)
19
+ - [Additional Extensions](#additional-extensions)
20
+ - [PhpStorm](#phpstorm)
17
21
 
18
- ## Installing
22
+ ## :package: Installing
19
23
 
20
24
  Include the config into your project:
21
25
 
@@ -37,12 +41,14 @@ module.exports = {
37
41
  };
38
42
  ```
39
43
 
44
+ ---
45
+
40
46
  ### Vue.js projects
41
47
 
42
48
  To use this config with a Vue.js project also install the following packages:
43
49
 
44
50
  ```shell
45
- npm install eslint-plugin-vue --save-dev --save-exact
51
+ npm install eslint-plugin-vue eslint-plugin-vuejs-accessibility --save-dev --save-exact
46
52
  ```
47
53
 
48
54
  And set the following extend in `.eslintrc.js`:
@@ -53,6 +59,8 @@ module.exports = {
53
59
  };
54
60
  ```
55
61
 
62
+ ---
63
+
56
64
  ### TypeScript projects
57
65
 
58
66
  To use this config with a TypeScript project also install the following packages
@@ -69,44 +77,28 @@ module.exports = {
69
77
  };
70
78
  ```
71
79
 
80
+ ---
81
+
72
82
  ### Vue.js, TypeScript and regular JavaScript together
73
83
 
74
- To use this config with all three types together, we need some custom settings:
84
+ To use this config with a Vue.js, TypeScript and regular JavaScript project also install the following packages
85
+
86
+ ```shell
87
+ npm install eslint-plugin-vue eslint-plugin-vuejs-accessibility @typescript-eslint/parser @typescript-eslint/eslint-plugin --save-dev --save-exact
88
+ ```
89
+
90
+ And set the following extend in `.eslintrc.js`:
75
91
 
76
92
  ```js
77
- const config = require('@bitfactory/eslint-config/index');
78
-
79
- config.overrides = [
80
- {
81
- files: ['**/*.ts', '**/*.tsx'],
82
- parser: '@typescript-eslint/parser',
83
- extends: [
84
- 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
85
- ],
86
- parserOptions: {
87
- ecmaFeatures: { jsx: true },
88
- ecmaVersion: 2018,
89
- sourceType: 'module',
90
- },
91
- },
92
- {
93
- files: ['**/*.vue'],
94
- parser: 'vue-eslint-parser',
95
- extends: [
96
- 'plugin:vue/essential', // Official eslint plugin for Vue.js
97
- ],
98
- parserOptions: {
99
- ecmaFeatures: { jsx: true },
100
- ecmaVersion: 2018,
101
- sourceType: 'module',
102
- },
103
- },
104
- ];
105
-
106
- module.exports = config;
107
- ```
108
-
109
- ## CLI usage
93
+ module.exports = {
94
+ extends: [
95
+ '@bitfactory/eslint-config/vue',
96
+ '@bitfactory/eslint-config/typescript',
97
+ ],
98
+ };
99
+ ```
100
+
101
+ ## :rocket: CLI usage
110
102
 
111
103
  To use ESLint in the command-line, add the following scripts to your projects `package.json`:
112
104
 
@@ -142,10 +134,31 @@ npm run eslint
142
134
  npm run eslint:fix
143
135
  ```
144
136
 
145
- ## Editor / IDE integration
137
+ ## :pencil2: Editor / IDE integration
146
138
 
147
139
  For ESLint to work, you need to set up your editor / IDE.
148
140
 
141
+ ### Visual Studio Code
142
+
143
+ 1. Install the [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension
144
+ 2. Add the following settings via `Code` → `Preferences` → `Settings`
145
+ 3. Get linting :rocket:
146
+
147
+ ```json
148
+ {
149
+ "editor.codeActionsOnSave": {
150
+ "source.fixAll.eslint": true
151
+ }
152
+ }
153
+ ```
154
+
155
+ #### Additional Extensions
156
+ - [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) to get inline error messages
157
+
158
+ > :warning: If you have the [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extension enabled, make sure to **disable** the extension for your project's workspace. This is because Prettier's rules will conflict with ours.
159
+
160
+ ---
161
+
149
162
  ### PhpStorm
150
163
 
151
164
  Go to [Preferences | Languages & Frameworks | JavaScript | Code Quality Tools | ESLint](jetbrains://PhpStorm/settings?name=Languages+%26+Frameworks--JavaScript--Code+Quality+Tools--ESLint) and set it to `Automatic ESLint configuration`
@@ -166,7 +179,7 @@ Working directory: $ProjectFileDir$
166
179
 
167
180
  You can also select JavaScript, Vue.js or TypeScript files for `File type`, and copy the watcher for each needed file to only check those files
168
181
 
169
- Or import the followinging xml file:
182
+ Or import the following xml file:
170
183
 
171
184
  ```xml
172
185
  <TaskOptions>
@@ -192,22 +205,3 @@ Or import the followinging xml file:
192
205
  </TaskOptions>
193
206
  </TaskOptions>
194
207
  ```
195
-
196
- ### Visual Studio Code
197
-
198
- 1. Install the [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension
199
- 2. Add the following settings via `Code` → `Preferences` → `Settings`
200
- 3. Get linting :rocket:
201
-
202
- ```json
203
- {
204
- "editor.codeActionsOnSave": {
205
- "source.fixAll.eslint": true
206
- }
207
- }
208
- ```
209
-
210
- #### Additional Extensions
211
- - [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) to get inline error messages
212
-
213
- > :warning: If you have the [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extension enabled, make sure to **disable** the extension for your project's workspace. This is because Prettier's rules will conflict with ours.
package/index.js CHANGED
@@ -1 +1,41 @@
1
- module.exports = require('./.eslintrc');
1
+ /* eslint-disable unicorn/prefer-module */
2
+
3
+ module.exports = {
4
+ env: {
5
+ browser: true,
6
+ es2021: true,
7
+ node: true,
8
+ },
9
+ extends: [
10
+ 'eslint:recommended',
11
+ 'plugin:jsdoc/recommended',
12
+ 'plugin:unicorn/recommended',
13
+ './rules/errors',
14
+ './rules/es6',
15
+ './rules/jsdoc',
16
+ './rules/practices',
17
+ './rules/style',
18
+ './rules/variables',
19
+ ],
20
+ ignorePatterns: [
21
+ '!.stylelintrc.js',
22
+ '/.nuxt/**',
23
+ '/dist/**',
24
+ '/static/sw.*',
25
+ ],
26
+ overrides: [
27
+ {
28
+ files: ['**/*.js'],
29
+ parser: '@babel/eslint-parser',
30
+ },
31
+ ],
32
+ parserOptions: {
33
+ ecmaVersion: 2021,
34
+ requireConfigFile: false,
35
+ sourceType: 'module',
36
+ },
37
+ plugins: [
38
+ 'jsdoc',
39
+ 'unicorn',
40
+ ],
41
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitfactory/eslint-config",
3
- "version": "1.1.4",
3
+ "version": "1.2.2",
4
4
  "description": "ESLint sharable config for Bitfactory projects",
5
5
  "keywords": [
6
6
  "eslint",
@@ -11,8 +11,7 @@
11
11
  "author": "Bitfactory",
12
12
  "main": "index.js",
13
13
  "files": [
14
- ".eslintrc.js",
15
- "configs",
14
+ "rules",
16
15
  "index.js",
17
16
  "README.md",
18
17
  "typescript.js",
@@ -23,35 +22,20 @@
23
22
  "eslint:fix": "npm run eslint -- --fix",
24
23
  "update:interactive": "npx npm-check -uE"
25
24
  },
26
- "husky": {
27
- "hooks": {
28
- "pre-commit": "lint-staged"
29
- }
30
- },
31
- "lint-staged": {
32
- "*.js": [
33
- "npm run eslint:fix",
34
- "git add"
35
- ],
36
- "package.json": [
37
- "npx sort-package-json",
38
- "git add"
39
- ]
40
- },
41
25
  "devDependencies": {
42
- "@babel/core": "^7.12.9",
43
- "@babel/eslint-parser": "^7.12.1",
44
- "eslint": "^7.14.0",
45
- "eslint-plugin-jsdoc": "^30.7.8",
46
- "eslint-plugin-unicorn": "^23.0.0",
47
- "husky": "^4.3.0",
48
- "lint-staged": "^10.5.2"
26
+ "@babel/core": "7.17.10",
27
+ "@babel/eslint-parser": "7.17.0",
28
+ "eslint": "8.15.0",
29
+ "eslint-plugin-jsdoc": "39.2.9",
30
+ "eslint-plugin-unicorn": "42.0.0",
31
+ "lint-staged": "12.4.1",
32
+ "simple-git-hooks": "2.7.0"
49
33
  },
50
34
  "peerDependencies": {
51
35
  "@babel/core": "^7.0.0",
52
36
  "@babel/eslint-parser": "^7.0.0",
53
37
  "eslint": "^7.0.0",
54
- "eslint-plugin-jsdoc": "^30.0.0",
55
- "eslint-plugin-unicorn": ">=23.0.0"
38
+ "eslint-plugin-jsdoc": ">=39.0.0",
39
+ "eslint-plugin-unicorn": ">=42.0.0"
56
40
  }
57
41
  }
@@ -1,5 +1,6 @@
1
+ /* eslint-disable unicorn/prefer-module */
2
+
1
3
  module.exports = {
2
- extends: ['eslint:recommended'],
3
4
  rules: {
4
5
  'no-await-in-loop': 'error',
5
6
  'no-console': 'error',
@@ -1,5 +1,6 @@
1
+ /* eslint-disable unicorn/prefer-module */
2
+
1
3
  module.exports = {
2
- extends: ['eslint:recommended'],
3
4
  rules: {
4
5
  'arrow-body-style': ['error', 'as-needed'],
5
6
  'arrow-parens': ['error', 'as-needed'],
@@ -1,6 +1,6 @@
1
+ /* eslint-disable unicorn/prefer-module */
2
+
1
3
  module.exports = {
2
- extends: ['eslint:recommended', 'plugin:jsdoc/recommended'],
3
- plugins: ['jsdoc'],
4
4
  rules: {
5
5
  'jsdoc/check-indentation': 'warn',
6
6
  'jsdoc/check-syntax': 'warn',
@@ -1,6 +1,6 @@
1
+ /* eslint-disable unicorn/prefer-module */
2
+
1
3
  module.exports = {
2
- extends: ['eslint:recommended', 'plugin:unicorn/recommended'],
3
- plugins: ['unicorn'],
4
4
  rules: {
5
5
  'array-callback-return': 'error',
6
6
  'block-scoped-var': 'error',
@@ -1,5 +1,6 @@
1
+ /* eslint-disable unicorn/prefer-module */
2
+
1
3
  module.exports = {
2
- extends: ['eslint:recommended'],
3
4
  rules: {
4
5
  'array-bracket-newline': ['error', 'consistent'],
5
6
  'array-bracket-spacing': 'error',
@@ -17,7 +18,9 @@ module.exports = {
17
18
  'func-names': ['error', 'never'],
18
19
  'func-style': 'error',
19
20
  'implicit-arrow-linebreak': 'error',
20
- 'indent': ['error', 4],
21
+ 'indent': ['error', 4, {
22
+ SwitchCase: 1,
23
+ }],
21
24
  'key-spacing': 'error',
22
25
  'keyword-spacing': 'error',
23
26
  'line-comment-position': 'error',
@@ -78,7 +81,24 @@ module.exports = {
78
81
  },
79
82
  ],
80
83
  'no-whitespace-before-property': 'error',
81
- 'object-curly-newline': 'off',
84
+ 'object-curly-newline': ['error', {
85
+ ExportDeclaration: {
86
+ minProperties: 2,
87
+ multiline: true,
88
+ },
89
+ ImportDeclaration: {
90
+ minProperties: 4,
91
+ multiline: true,
92
+ },
93
+ ObjectExpression: {
94
+ minProperties: 1,
95
+ multiline: true,
96
+ },
97
+ ObjectPattern: {
98
+ minProperties: 4,
99
+ multiline: true,
100
+ },
101
+ }],
82
102
  'object-curly-spacing': ['error', 'always'],
83
103
  'object-property-newline': 'error',
84
104
  'one-var': ['error', 'never'],
@@ -1,5 +1,6 @@
1
+ /* eslint-disable unicorn/prefer-module */
2
+
1
3
  module.exports = {
2
- extends: ['eslint:recommended'],
3
4
  rules: {
4
5
  'init-declarations': 'error',
5
6
  'no-label-var': 'error',
package/rules/vue.js ADDED
@@ -0,0 +1,27 @@
1
+ /* eslint-disable unicorn/prefer-module */
2
+
3
+ module.exports = {
4
+ rules: {
5
+ 'vuejs-accessibility/media-has-caption': 'off',
6
+ 'vue/block-tag-newline': [
7
+ 'error',
8
+ {
9
+ multiline: 'always',
10
+ singleline: 'always',
11
+ },
12
+ ],
13
+ 'vue/component-name-in-template-casing': [
14
+ 'error',
15
+ 'PascalCase',
16
+ {
17
+ registeredComponentsOnly: false,
18
+ },
19
+ ],
20
+ 'vue/html-indent': ['error', 4],
21
+ 'vue/no-empty-component-block': 'error',
22
+ 'vue/no-template-target-blank': 'error',
23
+ 'vue/padding-line-between-blocks': ['error', 'always'],
24
+ 'vue/singleline-html-element-content-newline': 'off',
25
+ 'vue/v-on-function-call': 'error',
26
+ },
27
+ };
package/typescript.js CHANGED
@@ -1,9 +1,17 @@
1
- const config = require('./.eslintrc');
1
+ /* eslint-disable unicorn/prefer-module */
2
2
 
3
- // Specifies the ESLint parser
4
- config.parser = '@typescript-eslint/parser';
5
- config.extends = [
6
- 'plugin:@typescript-eslint/recommended',
7
- ];
3
+ const base = require('.');
8
4
 
9
- module.exports = config;
5
+ module.exports = {
6
+ ...base,
7
+ overrides: [
8
+ ...base.overrides,
9
+ {
10
+ extends: [
11
+ 'plugin:@typescript-eslint/recommended',
12
+ ],
13
+ files: ['**/*.ts'],
14
+ parser: '@typescript-eslint/parser',
15
+ },
16
+ ],
17
+ };
package/vue.js CHANGED
@@ -1,5 +1,22 @@
1
- const config = require('./.eslintrc');
1
+ /* eslint-disable unicorn/prefer-module */
2
2
 
3
- config.extends.push('./configs/vue');
3
+ const base = require('.');
4
4
 
5
- module.exports = config;
5
+ module.exports = {
6
+ ...base,
7
+ overrides: [
8
+ ...base.overrides,
9
+ {
10
+ extends: [
11
+ 'plugin:vue/recommended',
12
+ 'plugin:vuejs-accessibility/recommended',
13
+ './rules/vue',
14
+ ],
15
+ files: ['**/*.vue'],
16
+ parser: 'vue-eslint-parser',
17
+ parserOptions: {
18
+ parser: '@babel/eslint-parser',
19
+ },
20
+ },
21
+ ],
22
+ };
package/.eslintrc.js DELETED
@@ -1,29 +0,0 @@
1
- module.exports = {
2
- env: {
3
- browser: true,
4
- es6: true,
5
- node: true,
6
- },
7
- extends: [
8
- './configs/errors',
9
- './configs/es6',
10
- './configs/jsdoc',
11
- './configs/practices',
12
- './configs/style',
13
- './configs/variables',
14
- ],
15
- ignorePatterns: [
16
- '!.stylelintrc.js',
17
- ],
18
- overrides: [
19
- {
20
- files: ['**/*.js'],
21
- parser: '@babel/eslint-parser',
22
- },
23
- ],
24
- parserOptions: {
25
- ecmaVersion: 2020,
26
- requireConfigFile: false,
27
- sourceType: 'module',
28
- },
29
- };
package/configs/vue.js DELETED
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- overrides: [
3
- {
4
- extends: [
5
- 'eslint:recommended',
6
- 'plugin:vue/vue3-recommended',
7
- ],
8
- files: ['*.vue'],
9
- parser: 'vue-eslint-parser',
10
- parserOptions: {
11
- ecmaVersion: 2020,
12
- parser: '@babel/eslint-parser',
13
- sourceType: 'module',
14
- },
15
- rules: {
16
- 'vue/html-indent': ['error', 4],
17
- },
18
- },
19
- ],
20
- };