@kitql/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.
@@ -0,0 +1,9 @@
1
+ const { plugins, ...prettierConfig } = require('@theguild/prettier-config')
2
+
3
+ module.exports = {
4
+ ...prettierConfig,
5
+ semi: false,
6
+ plugins: [...plugins, 'prettier-plugin-svelte', '@trivago/prettier-plugin-sort-imports'],
7
+ importOrder: ['<THIRD_PARTY_MODULES>', '^[./]'],
8
+ importOrderSeparation: true,
9
+ }
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2022 Jean-Yves Couët
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # 👌 @kitql/eslint-config
2
+
3
+ [![](https://img.shields.io/npm/v/@kitql/eslint-config?color=&logo=npm)](https://www.npmjs.com/package/@kitql/eslint-config)
4
+ [![](https://img.shields.io/npm/dm/@kitql/eslint-config?&logo=npm)](https://www.npmjs.com/package/@kitql/eslint-config)
5
+
6
+ ## 📖 Read the doc
7
+
8
+ [![](https://img.shields.io/badge/Documentation%20of-kitql%20lint%20format-FF3E00.svg?style=flat&logo=stackblitz&logoColor=FF3E00)](https://kitql.dev/docs)
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @kitql/eslint-config --D
14
+ ```
15
+
16
+ ### eslint config
17
+
18
+ `.eslintrc.js`
19
+ ```js
20
+ module.exports = {
21
+ extends: [
22
+ '@kitql',
23
+ ],
24
+ }
25
+ ```
26
+
27
+ ### prettier config
28
+
29
+ `.prettierrc.cjs`
30
+ ```js
31
+ const config = require('@kitql/eslint-config/.prettierrc.cjs')
32
+
33
+ module.exports = {
34
+ ...config,
35
+ // Some custom things?
36
+ }
37
+
38
+ ```
39
+
40
+ ### usage
41
+
42
+ ```bash
43
+ # lint
44
+ npm exec kitql-lint
45
+
46
+ # format
47
+ npm exec kitql-lint --format
48
+ ```
49
+
50
+ ## ⭐️ Join us
51
+
52
+ [![GitHub Repo stars](https://img.shields.io/github/stars/jycouet/kitql?logo=github&label=KitQL&color=#4ACC31)](https://github.com/jycouet/kitql)
53
+
54
+ 💡 _[KitQL](https://www.kitql.dev/docs) itself is not a library, it's "nothing" but a collection of standalone libraries._
55
+
package/cmd.js ADDED
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env node
2
+ import { spawn, spawnSync } from 'child_process'
3
+ import { program, Option } from 'commander'
4
+ import fs from 'fs'
5
+
6
+ program.addOption(new Option('-f, --format', 'format'))
7
+
8
+ program.parse(process.argv)
9
+ const options_cli = program.opts()
10
+
11
+ // console.info(`options_cli`, options_cli)
12
+
13
+ let pathPrettierIgnore = ''
14
+ try {
15
+ fs.statSync('.prettierignore')
16
+ pathPrettierIgnore = '.prettierignore'
17
+ } catch (error) {
18
+ try {
19
+ fs.statSync('../../.prettierignore')
20
+ pathPrettierIgnore = '../../.prettierignore'
21
+ } catch (error) {
22
+ // Still nothing
23
+ }
24
+ }
25
+ if (!pathPrettierIgnore) {
26
+ console.error(`.prettierignore not found`)
27
+ process.exit(0)
28
+ }
29
+
30
+ let pathPrettierCjs = ''
31
+ try {
32
+ fs.statSync('.prettierrc.cjs')
33
+ pathPrettierCjs = '.prettierrc.cjs'
34
+ } catch (error) {
35
+ try {
36
+ fs.statSync('../../.prettierrc.cjs')
37
+ pathPrettierCjs = '../../.prettierrc.cjs'
38
+ } catch (error) {
39
+ // Still nothing
40
+ }
41
+ }
42
+ if (!pathPrettierCjs) {
43
+ console.error(`.prettierrc.cjs not found`)
44
+ process.exit(0)
45
+ }
46
+
47
+ // --config <path>
48
+
49
+ const format = options_cli.format ?? false
50
+
51
+ // First prettier
52
+ const cmdPrettier =
53
+ `prettier` +
54
+ ` --list-different` +
55
+ // ignore?
56
+ ` --ignore-path ${pathPrettierIgnore}` +
57
+ // config
58
+ ` --config ${pathPrettierCjs}` +
59
+ // format or not
60
+ `${format ? ' --write' : ''}` +
61
+ // exec
62
+ ` .`
63
+ spawnSync(cmdPrettier, {
64
+ shell: true,
65
+ // cwd: process.cwd(),
66
+ stdio: 'inherit',
67
+ })
68
+
69
+ // Then eslint
70
+ const cmdEsLint =
71
+ `eslint` +
72
+ // ignore?
73
+ ` --ignore-path ${pathPrettierIgnore}` +
74
+ // format or not
75
+ `${format ? ' --fix' : ''} ` +
76
+ // exec
77
+ ` "*"`
78
+ spawnSync(cmdEsLint, {
79
+ shell: true,
80
+ // cwd: process.cwd(),
81
+ stdio: 'inherit',
82
+ })
83
+
84
+ // console.log(`cmdPrettier`, cmdPrettier)
85
+ // console.log(`cmdEsLint`, cmdEsLint)
package/index.cjs ADDED
@@ -0,0 +1,54 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: '@typescript-eslint/parser',
4
+ extends: [
5
+ '@theguild',
6
+ '@theguild/eslint-config/react',
7
+ '@theguild/eslint-config/mdx',
8
+ '@theguild/eslint-config/json',
9
+ '@theguild/eslint-config/yml',
10
+ 'eslint:recommended',
11
+ 'plugin:@typescript-eslint/recommended',
12
+ 'prettier',
13
+ 'plugin:svelte/recommended',
14
+ ],
15
+ plugins: ['unused-imports', 'svelte', '@typescript-eslint'],
16
+ rules: {
17
+ 'no-console': ['error', { allow: ['info', 'warn', 'error', 'time', 'timeEnd'] }],
18
+ 'unused-imports/no-unused-imports': 'error',
19
+ '@typescript-eslint/ban-ts-ignore': 'off',
20
+ '@typescript-eslint/ban-ts-comment': 'off',
21
+ '@typescript-eslint/no-explicit-any': 'off',
22
+ '@typescript-eslint/no-non-null-assertion': 'off',
23
+ '@typescript-eslint/ban-types': 'error',
24
+ },
25
+ overrides: [
26
+ {
27
+ files: ['*.svelte'],
28
+ parser: 'svelte-eslint-parser',
29
+ parserOptions: {
30
+ parser: '@typescript-eslint/parser',
31
+ },
32
+ },
33
+ {
34
+ files: ['*.graphql', '*.gql'],
35
+ parserOptions: {
36
+ operations: '**/*.gql',
37
+ schema: '**/*.graphql',
38
+ },
39
+ extends: ['plugin:@graphql-eslint/schema-all', 'plugin:@graphql-eslint/operations-all'],
40
+ rules: {
41
+ '@graphql-eslint/alphabetize': 'off',
42
+ },
43
+ },
44
+ ],
45
+ parserOptions: {
46
+ sourceType: 'module',
47
+ ecmaVersion: 2020,
48
+ },
49
+ env: {
50
+ browser: true,
51
+ es2017: true,
52
+ node: true,
53
+ },
54
+ }
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@kitql/eslint-config",
3
+ "description": "opinionated linting and formatting for projects",
4
+ "keywords": [
5
+ "cli"
6
+ ],
7
+ "version": "0.0.3",
8
+ "license": "MIT",
9
+ "type": "module",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/jycouet/kitql",
13
+ "directory": "packages/eslint-config",
14
+ "homepage": "https://github.com/jycouet/kitql/tree/main/packages/eslint-config"
15
+ },
16
+ "bin": {
17
+ "kitql-lint": "./cmd.js"
18
+ },
19
+ "main": "index.cjs",
20
+ "dependencies": {
21
+ "@graphql-eslint/eslint-plugin": "3.20.1",
22
+ "@theguild/eslint-config": "^0.11.1",
23
+ "@theguild/prettier-config": "2.0.2",
24
+ "@trivago/prettier-plugin-sort-imports": "4.3.0",
25
+ "@typescript-eslint/eslint-plugin": "6.14.0",
26
+ "@typescript-eslint/parser": "6.14.0",
27
+ "@vue/compiler-sfc": "3.3.4",
28
+ "commander": "^11.1.0",
29
+ "eslint": "8.55.0",
30
+ "eslint-config-prettier": "9.1.0",
31
+ "eslint-plugin-svelte": "2.35.0",
32
+ "eslint-plugin-unused-imports": "3.0.0",
33
+ "prettier": "3.1.0",
34
+ "prettier-plugin-sh": "0.13.1",
35
+ "prettier-plugin-svelte": "3.1.0",
36
+ "prettier-plugin-tailwindcss": "0.5.7",
37
+ "svelte": "4.2.0",
38
+ "typescript": "5.3.2"
39
+ },
40
+ "sideEffects": false,
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "files": [
45
+ "index.cjs",
46
+ "cmd.sh",
47
+ "cmd.js",
48
+ ".eslintrc.cjs",
49
+ ".prettierrc.cjs"
50
+ ],
51
+ "scripts": {
52
+ "dev": "node ./cmd.js",
53
+ "lint:example": "kitql-lint",
54
+ "format:example": "kitql-lint --format"
55
+ }
56
+ }