@rgb72/coding-standards 0.0.0-stage → 0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rgb72
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,93 @@
1
- # Temporary Holding Version
1
+ # rgb72 Coding Standards
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared code style for rgb72 projects — **Laravel** (PHP CS Fixer) and **Vue 3 + Vuetify** on Nuxt or Laravel + Vite/Inertia (ESLint, Prettier, Stylelint), plus a common `.editorconfig`.
4
+
5
+ | Tool | Package | Import |
6
+ |---|---|---|
7
+ | Prettier | `@rgb72/coding-standards` (npm) | `@rgb72/coding-standards/prettier` |
8
+ | ESLint | `@rgb72/coding-standards` (npm) | `@rgb72/coding-standards/eslint` |
9
+ | Stylelint | `@rgb72/coding-standards` (npm) | `@rgb72/coding-standards/stylelint` |
10
+ | PHP CS Fixer | `rgb72/coding-standards` (Composer) | `Rgb72\CodingStandards\PhpCsFixer\Config` |
11
+ | EditorConfig | both | copied by `rgb72-standards init` |
12
+
13
+ ## Frontend (Nuxt or Laravel + Vite)
14
+
15
+ ```bash
16
+ # Nuxt (requires @nuxt/eslint)
17
+ npm i -D @rgb72/coding-standards eslint prettier stylelint
18
+ npx rgb72-standards init --nuxt
19
+
20
+ # Laravel + Vite / Inertia / Vuexy
21
+ npm i -D @rgb72/coding-standards eslint prettier stylelint eslint-plugin-vue typescript-eslint
22
+ npx rgb72-standards init --vite
23
+ ```
24
+
25
+ Creates `.editorconfig`, `eslint.config.mjs`, `prettier.config.mjs`, `stylelint.config.mjs` and `.prettierignore`. Existing files are skipped (`--force` to overwrite), and legacy configs (`.prettierrc`, `.eslintrc.cjs`, `.stylelintrc.json`) are reported so you can delete them — Prettier picks `.prettierrc` over `prettier.config.mjs` if both exist.
26
+
27
+ ### Style at a glance
28
+
29
+ - No semicolons, single quotes, trailing commas, `printWidth: 120`, 2-space indent (4 for PHP)
30
+ - One attribute per line in templates
31
+ - Imports sorted by `@ianvs/prettier-plugin-sort-imports`: types → built-ins/packages → `@/` aliases → `@/*.vue` components → relative
32
+ - Vuetify components in **PascalCase** (`<VBtn>`), `<script setup>` only, block order script → template → style
33
+ - SCSS: idiomatic property order, logical properties (`margin-inline` not `margin-left`)
34
+
35
+ ### Vuexy projects
36
+
37
+ Keep Vuexy-only rules in the project, not here: path-alias `importOrder` (example in the `prettier.config.mjs` stub), `regex/invalid` alias rules, `valid-appcardcode-*`, and `no-restricted-imports` for auto-imported packages. Add them to the `project` block of `eslint.config.mjs`.
38
+
39
+ ## Laravel
40
+
41
+ PSR-12 base, `declare(strict_types=1)`, short arrays, `'Hello ' . $name` concat spacing, sorted/unused imports cleaned, Laravel-style `! $x`.
42
+
43
+ ```bash
44
+ composer require --dev rgb72/coding-standards
45
+ vendor/bin/rgb72-standards init
46
+ vendor/bin/php-cs-fixer fix
47
+ ```
48
+
49
+ ```php
50
+ // .php-cs-fixer.dist.php
51
+ use Rgb72\CodingStandards\PhpCsFixer\Config;
52
+
53
+ return Config::make(
54
+ Config::laravelFinder(__DIR__),
55
+ ['final_class' => true], // optional project overrides
56
+ );
57
+ ```
58
+
59
+ Suggested `composer.json` scripts:
60
+
61
+ ```json
62
+ "scripts": {
63
+ "lint": "php-cs-fixer fix --dry-run --diff",
64
+ "fix": "php-cs-fixer fix"
65
+ }
66
+ ```
67
+
68
+ ## Developing locally
69
+
70
+ Link the working copy into a project instead of publishing:
71
+
72
+ ```bash
73
+ # Nuxt
74
+ npm i -D ~/Workspace/Libraries/coding-standards
75
+ ```
76
+
77
+ ```json
78
+ // Laravel composer.json
79
+ "repositories": [
80
+ { "type": "path", "url": "~/Workspace/Libraries/coding-standards", "options": { "symlink": true } }
81
+ ]
82
+ ```
83
+
84
+ Run tests with `npm test`.
85
+
86
+ ## Releasing
87
+
88
+ 1. Update `version` in `package.json` and `CHANGELOG.md`
89
+ 2. `git flow release start 1.2.0`, commit, then `git flow release finish 1.2.0 -m "release: 🏹1.2.0"` (tag `v1.2.0`)
90
+ 3. `git push origin main develop --follow-tags`
91
+ 4. GitLab CI publishes to npm on the `v*` tag (Trusted Publishing, OIDC — no token); Packagist updates via the GitLab integration
92
+
93
+ See `CHANGELOG.md` for the semver policy.
package/bin/init.mjs ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ // npx rgb72-standards init --nuxt|--vite [--force]
3
+ // Copies frontend config files from stubs/ into the current project.
4
+ import { copyFileSync, existsSync } from 'node:fs'
5
+ import { dirname, join } from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
7
+
8
+ const stubs = join(dirname(fileURLToPath(import.meta.url)), '..', 'stubs')
9
+ const [command, ...flags] = process.argv.slice(2)
10
+ const force = flags.includes('--force')
11
+ const preset = flags.includes('--nuxt') ? 'nuxt' : flags.includes('--vite') ? 'vite' : null
12
+
13
+ const usage = `Usage: rgb72-standards init --nuxt|--vite [--force]
14
+
15
+ --nuxt Nuxt project (uses @nuxt/eslint's withNuxt)
16
+ --vite Laravel + Vite / Inertia / Vuexy project
17
+ --force Overwrite existing files`
18
+
19
+ if (command !== 'init' || !preset) {
20
+ console.log(usage)
21
+ process.exit(command ? 1 : 0)
22
+ }
23
+
24
+ const files = [
25
+ ['.editorconfig', '.editorconfig'],
26
+ ['.prettierignore', '.prettierignore'],
27
+ ['prettier.config.mjs', 'prettier.config.mjs'],
28
+ ['stylelint.config.mjs', 'stylelint.config.mjs'],
29
+ [`${preset}/eslint.config.mjs`, 'eslint.config.mjs'],
30
+ ]
31
+
32
+ for (const [from, to] of files) {
33
+ const target = join(process.cwd(), to)
34
+ if (existsSync(target) && !force) {
35
+ console.log(`skip ${to} (exists, use --force to overwrite)`)
36
+ continue
37
+ }
38
+ copyFileSync(join(stubs, from), target)
39
+ console.log(`created ${to}`)
40
+ }
41
+
42
+ const legacy = ['.prettierrc', '.prettierrc.json', '.prettierrc.ts', '.eslintrc.cjs', '.eslintrc.js', '.eslintrc.json', '.stylelintrc.json']
43
+ .filter(f => existsSync(join(process.cwd(), f)))
44
+ if (legacy.length) {
45
+ console.warn(`\n⚠ Remove legacy config so the new files take effect: ${legacy.join(', ')}`)
46
+ }
@@ -0,0 +1,52 @@
1
+ import vuetify from 'eslint-plugin-vuetify'
2
+
3
+ /**
4
+ * Shared ESLint flat config for Vue 3 + Vuetify projects.
5
+ * Framework-agnostic: works with Nuxt (`withNuxt(...rgb72)`) and
6
+ * Laravel + Vite (spread after `eslint-plugin-vue` configs). See stubs/.
7
+ *
8
+ * Formatting is Prettier's job — no stylistic rules here.
9
+ *
10
+ * @type {import('eslint').Linter.Config[]}
11
+ */
12
+ export default [
13
+ ...vuetify.configs['flat/base'],
14
+ {
15
+ name: 'rgb72/vue',
16
+ files: ['**/*.vue'],
17
+ rules: {
18
+ 'vue/block-order': ['error', { order: ['script', 'template', 'style'] }],
19
+ 'vue/component-api-style': ['error', ['script-setup']],
20
+ 'vue/component-name-in-template-casing': ['error', 'PascalCase', { registeredComponentsOnly: false }],
21
+ 'vue/custom-event-name-casing': ['error', 'camelCase'],
22
+ 'vue/define-macros-order': ['error', { order: ['defineOptions', 'defineProps', 'defineEmits', 'defineSlots'] }],
23
+ 'vue/multi-word-component-names': 'off',
24
+ 'vue/no-empty-component-block': 'error',
25
+ 'vue/no-template-target-blank': 'error',
26
+ 'vue/no-unused-refs': 'warn',
27
+ 'vue/no-useless-mustaches': 'error',
28
+ 'vue/no-useless-v-bind': 'error',
29
+ 'vue/padding-line-between-blocks': 'error',
30
+ 'vue/prefer-separate-static-class': 'error',
31
+ 'vue/prefer-true-attribute-shorthand': 'error',
32
+ 'vue/require-default-prop': 'off',
33
+ 'vue/valid-v-slot': ['error', { allowModifiers: true }],
34
+ },
35
+ },
36
+ {
37
+ name: 'rgb72/js',
38
+ rules: {
39
+ 'camelcase': ['error', { properties: 'never' }],
40
+ 'eqeqeq': ['error', 'smart'],
41
+ 'no-console': ['warn', { allow: ['warn', 'error'] }],
42
+ 'no-debugger': 'error',
43
+ 'prefer-const': 'error',
44
+ 'padding-line-between-statements': [
45
+ 'error',
46
+ { blankLine: 'always', prev: '*', next: 'return' },
47
+ { blankLine: 'always', prev: 'multiline-const', next: '*' },
48
+ { blankLine: 'always', prev: '*', next: 'multiline-const' },
49
+ ],
50
+ },
51
+ },
52
+ ]
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "@rgb72/coding-standards",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Shared Prettier, ESLint, Stylelint, EditorConfig and PHP CS Fixer config for rgb72 projects (Laravel + Vue/Vuetify)",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://gitlab.com/rgb72/coding-standards.git"
10
+ },
11
+ "exports": {
12
+ "./prettier": "./prettier/index.mjs",
13
+ "./eslint": "./eslint/index.mjs",
14
+ "./stylelint": "./stylelint/index.mjs"
15
+ },
16
+ "bin": {
17
+ "rgb72-standards": "bin/init.mjs"
18
+ },
19
+ "files": [
20
+ "prettier",
21
+ "eslint",
22
+ "stylelint",
23
+ "bin/init.mjs",
24
+ "stubs/.editorconfig",
25
+ "stubs/.prettierignore",
26
+ "stubs/prettier.config.mjs",
27
+ "stubs/stylelint.config.mjs",
28
+ "stubs/nuxt",
29
+ "stubs/vite"
30
+ ],
31
+ "scripts": {
32
+ "test": "node --test \"tests/**/*.test.mjs\""
33
+ },
34
+ "dependencies": {
35
+ "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
36
+ "@stylistic/stylelint-config": "^5.0.0",
37
+ "@stylistic/stylelint-plugin": "^5.0.0",
38
+ "eslint-plugin-vuetify": "^2.5.0",
39
+ "postcss-html": "^1.8.0",
40
+ "postcss-scss": "^4.0.9",
41
+ "stylelint-config-idiomatic-order": "^10.0.0",
42
+ "stylelint-config-standard-scss": "^17.0.0",
43
+ "stylelint-use-logical-spec": "^6.0.1"
44
+ },
45
+ "peerDependencies": {
46
+ "eslint": "^9.22.0",
47
+ "prettier": "^3.0.0",
48
+ "stylelint": "^17.6.0"
49
+ },
50
+ "devDependencies": {
51
+ "eslint": "^9.22.0",
52
+ "eslint-plugin-vue": "^10.0.0",
53
+ "prettier": "^3.0.0",
54
+ "stylelint": "^17.6.0",
55
+ "typescript": "^5.9.0",
56
+ "typescript-eslint": "^8.73.0"
57
+ },
58
+ "engines": {
59
+ "node": ">=20"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public",
63
+ "provenance": true
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "stylelint": {
67
+ "optional": true
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,47 @@
1
+ import * as sortImports from '@ianvs/prettier-plugin-sort-imports'
2
+
3
+ /**
4
+ * Shared Prettier config.
5
+ *
6
+ * Projects with extra path aliases (e.g. Vuexy's @core, @layouts, @images)
7
+ * override `importOrder` — see README.
8
+ *
9
+ * @type {import('prettier').Config & import('@ianvs/prettier-plugin-sort-imports').PluginConfig}
10
+ */
11
+ export default {
12
+ semi: false,
13
+ singleQuote: true,
14
+ trailingComma: 'all',
15
+ printWidth: 120,
16
+ tabWidth: 2,
17
+ useTabs: false,
18
+ arrowParens: 'avoid',
19
+ bracketSpacing: true,
20
+ quoteProps: 'consistent',
21
+ endOfLine: 'lf',
22
+ vueIndentScriptAndStyle: false,
23
+ singleAttributePerLine: true,
24
+ htmlWhitespaceSensitivity: 'css',
25
+
26
+ plugins: [sortImports],
27
+ importOrder: [
28
+ '<TYPES>',
29
+ '',
30
+ '<BUILTIN_MODULES>',
31
+ '<THIRD_PARTY_MODULES>',
32
+ '',
33
+ '^[@~#]/(?!.*\\.vue$)(.*)$',
34
+ '',
35
+ '^[@~#]/(.*)\\.vue$',
36
+ '',
37
+ '^[./]',
38
+ ],
39
+ importOrderTypeScriptVersion: '5.0.0',
40
+
41
+ overrides: [
42
+ {
43
+ files: ['*.php', '*.blade.php'],
44
+ options: { tabWidth: 4 },
45
+ },
46
+ ],
47
+ }
@@ -0,0 +1,24 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.php]
12
+ indent_size = 4
13
+
14
+ [*.blade.php]
15
+ indent_size = 4
16
+
17
+ [*.md]
18
+ trim_trailing_whitespace = false
19
+
20
+ [{Makefile,*.mk}]
21
+ indent_style = tab
22
+
23
+ [docker-compose.{yml,yaml}]
24
+ indent_size = 4
@@ -0,0 +1,23 @@
1
+ # Build output
2
+ .nuxt
3
+ .output
4
+ .data
5
+ dist
6
+ coverage
7
+ public/build
8
+
9
+ # Dependencies
10
+ node_modules
11
+ vendor
12
+
13
+ # Laravel
14
+ storage
15
+ bootstrap/cache
16
+ *.blade.php
17
+
18
+ # Lockfiles & generated
19
+ package-lock.json
20
+ pnpm-lock.yaml
21
+ composer.lock
22
+ *.min.*
23
+ *.d.ts
@@ -0,0 +1,4 @@
1
+ import withNuxt from './.nuxt/eslint.config.mjs'
2
+ import rgb72 from '@rgb72/coding-standards/eslint'
3
+
4
+ export default withNuxt(...rgb72)
@@ -0,0 +1,15 @@
1
+ import rgb72 from '@rgb72/coding-standards/prettier'
2
+
3
+ /** @type {import('prettier').Config} */
4
+ export default {
5
+ ...rgb72,
6
+ // Vuexy projects: add aliases to importOrder, e.g.
7
+ // importOrder: [
8
+ // '<TYPES>', '', '<BUILTIN_MODULES>', '<THIRD_PARTY_MODULES>', '',
9
+ // '^@(themeConfig|layouts)(/.*)?$', '',
10
+ // '^@/(?!.*\\.vue$)(.*)$',
11
+ // '^@(core-scss|core|images|styles|configured-variables)(/.*)?$', '',
12
+ // '^@/(.*)\\.vue$', '',
13
+ // '^[./]',
14
+ // ],
15
+ }
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ export default {
3
+ extends: ['@rgb72/coding-standards/stylelint'],
4
+ }
@@ -0,0 +1,25 @@
1
+ import { defineConfig } from 'eslint/config'
2
+ import vue from 'eslint-plugin-vue'
3
+ import tseslint from 'typescript-eslint'
4
+ import rgb72 from '@rgb72/coding-standards/eslint'
5
+
6
+ export default defineConfig(
7
+ {
8
+ ignores: ['public/**', 'vendor/**', 'storage/**', 'bootstrap/cache/**', '**/*.d.ts'],
9
+ },
10
+ ...tseslint.configs.recommended,
11
+ ...vue.configs['flat/recommended'],
12
+ {
13
+ files: ['**/*.vue'],
14
+ languageOptions: { parserOptions: { parser: tseslint.parser } },
15
+ },
16
+ ...rgb72,
17
+ {
18
+ name: 'project',
19
+ rules: {
20
+ '@typescript-eslint/consistent-type-imports': 'error',
21
+ '@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }],
22
+ // Project-specific rules (e.g. Vuexy path aliases) go here
23
+ },
24
+ },
25
+ )
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared Stylelint config for SCSS + Vue SFC styles (Vuetify / Vuexy).
3
+ *
4
+ * Usage (stylelint.config.mjs):
5
+ * export default { extends: ['@rgb72/coding-standards/stylelint'] }
6
+ *
7
+ * @type {import('stylelint').Config}
8
+ */
9
+ export default {
10
+ extends: [
11
+ 'stylelint-config-standard-scss',
12
+ 'stylelint-config-idiomatic-order',
13
+ '@stylistic/stylelint-config',
14
+ ],
15
+ plugins: ['stylelint-use-logical-spec', '@stylistic/stylelint-plugin'],
16
+ overrides: [
17
+ { files: ['**/*.scss'], customSyntax: 'postcss-scss' },
18
+ { files: ['**/*.vue'], customSyntax: 'postcss-html' },
19
+ ],
20
+ rules: {
21
+ '@stylistic/indentation': 2,
22
+ '@stylistic/string-quotes': 'single',
23
+ '@stylistic/max-line-length': [120, { ignore: ['comments'] }],
24
+ 'liberty/use-logical-spec': true,
25
+ 'selector-class-pattern': null,
26
+ 'color-function-notation': null,
27
+ 'media-feature-range-notation': null,
28
+ 'shorthand-property-no-redundant-values': null,
29
+ 'annotation-no-unknown': [true, { ignoreAnnotations: ['default'] }],
30
+ },
31
+ }