eslint-plugin-vue-kuzzle 0.0.8

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,48 @@
1
+ # eslint-plugin-vue-kuzzle
2
+
3
+ Kuzzle Coding Standard for Vue.js.
4
+
5
+ This plugin is standalone, meaning that `eslint` and `prettier` are included in the package so you don't need to install them yourself.
6
+
7
+ ## Install our coding standard
8
+
9
+ 1) Install the plugin
10
+
11
+ ```sh
12
+ npm i eslint-plugin-vue-kuzzle --save-dev
13
+ ```
14
+
15
+ 2) Add `kuzzle` to the plugins section of your `.eslintrc` configuration file and select the default rule set:
16
+
17
+ ```json
18
+ {
19
+ "extends": [
20
+ "plugin:vue-kuzzle/defaultt",
21
+ "plugin:vue-kuzzle/base",
22
+ "plugin:vue-kuzzle/typescript"
23
+ ]
24
+ }
25
+ ```
26
+
27
+ 3) Remove unused eslint-related dependencies (such as `@vue/eslint-config-standard`, `eslint` etc)
28
+
29
+ 4) Commit relevant files
30
+
31
+ ## Available rule sets
32
+
33
+ - `plugin:vue-kuzzle/default`: default combines base and typecript rules sets
34
+ - `plugin:vue-kuzzle/base`: rules for only Javascript projects
35
+ - `plugin:vue-kuzzle/typescript`: rules for Typescript projects
36
+
37
+ You can disable the `import/order` rule on project that are not libraries:
38
+
39
+ ```json
40
+ {
41
+ "extends": [
42
+ "plugin:vue-kuzzle/default",
43
+ ],
44
+ "rules": {
45
+ "import/order": ["off"]
46
+ }
47
+ }
48
+ ```
@@ -0,0 +1,12 @@
1
+ const importOptions = require('../importOption');
2
+
3
+ module.exports = {
4
+ extends: ['plugin:vue/recommended', '@vue/standard', '@vue/prettier'],
5
+ rules: {
6
+ 'no-console': ['error', { allow: ['warn', 'error'] }],
7
+ 'no-debugger': 'error',
8
+ 'import/order': ['error', importOptions(['~', '@'])],
9
+ 'prefer-arrow-callback': 'error',
10
+ 'arrow-body-style': ['error', 'as-needed'],
11
+ },
12
+ };
@@ -0,0 +1,19 @@
1
+ const baseConfig = require('./base');
2
+ const typescriptConfig = require('./typescript');
3
+
4
+ module.exports = {
5
+ ...baseConfig,
6
+ overrides: [
7
+ {
8
+ files: ['vite.config.ts'],
9
+ parserOptions: {
10
+ parser: '@typescript-eslint/parser',
11
+ },
12
+ },
13
+ {
14
+ // Apply vue and typescript rules only on Vue SFC and typescript files
15
+ files: ['src/**/*.{vue,ts}'],
16
+ ...typescriptConfig,
17
+ },
18
+ ],
19
+ };
@@ -0,0 +1,45 @@
1
+ module.exports = {
2
+ parser: 'vue-eslint-parser',
3
+ parserOptions: {
4
+ parser: '@typescript-eslint/parser',
5
+ },
6
+ extends: [
7
+ '@vue/typescript/recommended',
8
+ '@vue/eslint-config-standard-with-typescript',
9
+ // Need to repeat prettier here to keep rules priority over previous rulesset
10
+ '@vue/prettier',
11
+ ],
12
+ rules: {
13
+ // Normalize eqeqeq rules in template like in script
14
+ 'vue/eqeqeq': ['error', 'always'],
15
+ // Force self-closing to improve readability of templates
16
+ 'vue/html-self-closing': [
17
+ 'error',
18
+ {
19
+ html: {
20
+ void: 'any',
21
+ normal: 'always',
22
+ component: 'always',
23
+ },
24
+ svg: 'always',
25
+ math: 'always',
26
+ },
27
+ ],
28
+ /**
29
+ * Force consistent type imports
30
+ *
31
+ * @see https://typescript-eslint.io/blog/consistent-type-imports-and-exports-why-and-how/
32
+ */
33
+ '@typescript-eslint/consistent-type-imports': [
34
+ 'error',
35
+ {
36
+ disallowTypeAnnotations: true,
37
+ fixStyle: 'inline-type-imports',
38
+ prefer: 'type-imports',
39
+ },
40
+ ],
41
+ '@typescript-eslint/no-import-type-side-effects': 'error',
42
+ // Normalize methode signature style
43
+ '@typescript-eslint/method-signature-style': 'error',
44
+ },
45
+ };
@@ -0,0 +1,27 @@
1
+ // ? Eslint plugin rules are not applicable for this function, because it's not a code of eslint rule
2
+ /* eslint-disable eslint-plugin/prefer-message-ids, eslint-plugin/prefer-object-rule, eslint-plugin/require-meta-type, eslint-plugin/require-meta-schema */
3
+ module.exports = (alias) => {
4
+ const aliases = Array.isArray(alias) ? alias : [alias];
5
+
6
+ return {
7
+ groups: ['builtin', 'external', 'parent', 'sibling'],
8
+ pathGroups: [
9
+ { pattern: 'vue', group: 'external', position: 'before' },
10
+ // ? Patterns should be sorting of more precise to more generic
11
+ ...aliases.map((alias) => ({ pattern: `${alias}/**/*.vue`, group: 'sibling' })),
12
+ { pattern: './**/*.vue', group: 'sibling', position: 'after' },
13
+ ...aliases.map((alias) => ({ pattern: `${alias}/**/*`, group: 'parent' })),
14
+ { pattern: './**/*', group: 'parent', position: 'after' },
15
+ ],
16
+ /**
17
+ * ? Particular case: need to exclude `vue` of external import group to can be sorted with pattern
18
+ * @see https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#pathgroupsexcludedimporttypes-array
19
+ */
20
+ pathGroupsExcludedImportTypes: ['vue'],
21
+ 'newlines-between': 'always',
22
+ distinctGroup: false,
23
+ alphabetize: {
24
+ order: 'asc',
25
+ },
26
+ };
27
+ };
package/lib/index.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ configs: {
3
+ default: require('./configs/default'),
4
+ base: require('./configs/base'),
5
+ typescript: require('./configs/typescript'),
6
+ },
7
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "eslint-plugin-vue-kuzzle",
3
+ "version": "0.0.8",
4
+ "description": "Kuzzle Vue Coding Standard",
5
+ "homepage": "https://github.com/kuzzleio/eslint-plugin-kuzzle",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/kuzzleio/eslint-plugin-kuzzle.git",
9
+ "directory": "packages/frontend"
10
+ },
11
+ "keywords": [
12
+ "eslint",
13
+ "eslint-plugin",
14
+ "vue",
15
+ "kuzzle"
16
+ ],
17
+ "author": "The Kuzzle Team",
18
+ "main": "lib/index.js",
19
+ "scripts": {
20
+ "lint": "eslint lib"
21
+ },
22
+ "dependencies": {
23
+ "@vue/eslint-config-prettier": "8.0.*",
24
+ "@vue/eslint-config-standard": "8.0.*",
25
+ "@vue/eslint-config-standard-with-typescript": "8.0.*",
26
+ "@vue/eslint-config-typescript": "11.0.*"
27
+ },
28
+ "devDependencies": {
29
+ "eslint-plugin-eslint-plugin": "^5.0.6"
30
+ },
31
+ "license": "Apache 2",
32
+ "files": [
33
+ "lib/",
34
+ "README.md",
35
+ "package.json"
36
+ ],
37
+ "exports": {
38
+ ".": "./lib/index.js",
39
+ "./importOption": "./lib/importOption.js"
40
+ },
41
+ "engines": {
42
+ "node": ">=16.0.0"
43
+ }
44
+ }