Skip to content

Instantly share code, notes, and snippets.

@philsinatra
Last active June 24, 2025 18:43
Show Gist options
  • Save philsinatra/3f1bd2e1cb2a4d4408318697400085fe to your computer and use it in GitHub Desktop.
Save philsinatra/3f1bd2e1cb2a4d4408318697400085fe to your computer and use it in GitHub Desktop.
Linting and Formatting Configuration
Linting and Formatting Configuration Files
{
"alt-require": true,
"attr-lowercase": true,
"attr-no-duplication": true,
"attr-value-double-quotes": true,
"doctype-first": true,
"doctype-html5": true,
"id-unique": true,
"spec-char-escape": true,
"src-not-empty": true,
"tag-pair": true,
"tagname-lowercase": true,
"title-require": false
}
<?php
require_once __DIR__ . '/vendor/autoload.php';
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$config = new Config();
return $config
->setRules([
'array_syntax' => ['syntax' => 'short'],
'blank_line_after_namespace' => true,
'braces' => [
'position_after_functions_and_oop_constructs' => 'same',
'allow_single_line_closure' => true,
'position_after_control_structures' => 'same',
'position_after_anonymous_constructs' => 'same',
],
'class_definition' => true,
'encoding' => true,
'full_opening_tag' => true,
'line_ending' => true,
'method_argument_space' => true,
'multiline_comment_opening_closing' => true,
'no_blank_lines_after_phpdoc' => true,
'no_unused_imports' => true,
'ordered_imports' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'single_blank_line_at_eof' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => [
'comment_types' => ['hash']
],
'strict_boolean' => false,
'strict_comparison' => false,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'visibility_required' => true,
])
->setFinder(
Finder::create()
->exclude('vendor')
->in(__DIR__)
);
{
"extends": [
"stylelint-config-standard",
"stylelint-config-recommended",
"stylelint-config-alphabetical-order",
"stylelint-config-html"
],
"customSyntax": "postcss-html",
"plugins": [
"stylelint-value-no-unknown-custom-properties",
"stylelint-order"
],
"overrides": [
{
"files": ["**/*.svelte"],
"customSyntax": "postcss-html"
},
{
"files": ["**/*.css"],
"customSyntax": "postcss"
}
],
"rules": {
"alpha-value-notation": "number",
"color-named": "never",
"comment-empty-line-before": [
"never",
{
"ignore": ["after-comment", "stylelint-commands"],
"ignoreComments": ["#endregion", "/#region/"]
}
],
"csstools/value-no-unknown-custom-properties": [
true,
{
"importFrom": ["./src/css/screen.css"]
}
],
"custom-property-pattern": [
"^([a-z][a-z0-9]*)(-[a-z0-9]+)*$",
{
"message": "Expected custom property name to be kebab-case"
}
],
"declaration-property-value-disallowed-list": {
"background-color": ["/^(?!var\\(--).+/"],
"border-color": ["/^(?!var\\(--).+/"],
"border-top-color": ["/^(?!var\\(--).+/"],
"border-right-color": ["/^(?!var\\(--).+/"],
"border-bottom-color": ["/^(?!var\\(--).+/"],
"border-left-color": ["/^(?!var\\(--).+/"],
"color": ["/^(?!var\\(--).+/"]
},
"declaration-property-value-no-unknown": [
true,
{
"ignoreProperties": { "grid-area": "/.+/" }
}
],
"font-family-no-missing-generic-family-keyword": null,
"import-notation": "string",
"value-keyword-case": [
"lower",
{
"ignoreKeywords": ["Geist", "GeistMono", "Arial"]
}
]
}
}
{
"name": "svelte-config-test",
"private": true,
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"prepare": "svelte-kit sync || echo ''",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"lint:style": "stylelint \"**/*.{css,svelte}\""
},
"devDependencies": {
"@eslint/compat": "^1.2.5",
"@eslint/js": "^9.18.0",
"@sveltejs/adapter-auto": "^6.0.0",
"@sveltejs/kit": "^2.16.0",
"@sveltejs/vite-plugin-svelte": "^5.0.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-svelte": "^3.0.0",
"globals": "^16.0.0",
"postcss-html": "^1.8.0",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.3",
"stylelint": "^16.19.1",
"stylelint-config-alphabetical-order": "^1.0.0",
"stylelint-config-html": "^1.1.0",
"stylelint-config-recommended": "^16.0.0",
"stylelint-config-standard": "^38.0.0",
"stylelint-value-no-unknown-custom-properties": "^6.0.1",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"typescript": "^5.0.0",
"typescript-eslint": "^8.20.0",
"vite": "^6.2.6"
}
}
<?xml version="1.0"?>
<ruleset name="PJS">
<description>Custom PHPCS Ruleset</description>
<exclude-pattern>vendor/*</exclude-pattern>
<!-- <rule ref="PSR12"></rule> -->
<!-- Include the whole PEAR standard -->
<rule ref="PEAR">
<exclude name="PEAR.NamingConventions.ValidFunctionName"/>
<exclude name="PEAR.NamingConventions.ValidVariableName"/>
<exclude name="PEAR.Commenting.ClassComment"/>
<exclude name="PEAR.Commenting.FileComment.IncorrectAuthor"/>
<exclude name="PEAR.Commenting.FileComment.MissingCategoryTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingPackageTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingLicenseTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingLinkTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingVersion"/>
<rule ref="PEAR.Commenting.FunctionComment">
<exclude name="PEAR.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="PEAR.Commenting.FunctionComment.MissingParamTag"/>
</rule>
<exclude name="PEAR.Commenting.InlineComment"/>
<exclude name="PEAR.Functions.FunctionDeclaration"/>
<exclude name="PEAR.WhiteSpace.ScopeClosingBrace"/>
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman"/>
<exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace"/>
<exclude name="PSR2.Methods.FunctionClosingBrace"/>
<!-- <exclude name="PEAR.Commenting.BlockComment"/> -->
<exclude name="Squiz.Commenting.BlockComment"/>
<exclude name="Squiz.Commenting.InlineComment"/>
<exclude name="Squiz.Commenting.PostStatementComment"/>
</rule>
<!-- Include some sniffs from other standards that don't conflict with PEAR -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Arrays.ArrayDeclaration"/>
<rule ref="Squiz.Commenting.ClosingDeclarationComment"/>
<rule ref="Squiz.ControlStructures.ControlSignature"/>
<rule ref="Squiz.ControlStructures.ElseIfDeclaration"/>
<rule ref="Squiz.Commenting.BlockComment"/>
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
<rule ref="Squiz.Commenting.FileComment">
<exclude name="Squiz.Commenting.FileComment.IncorrectAuthor"/>
<exclude name="Squiz.Commenting.FileComment.MissingExtensionTag"/>
<exclude name="Squiz.Commenting.FileComment.MissingLicenseTag"/>
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag"/>
<exclude name="Squiz.Commenting.FileComment.MissingSubpackageTag"/>
<exclude name="Squiz.Commenting.FileComment.PackageTagOrder"/>
<exclude name="Squiz.Commenting.FileComment.SubpackageTagOrder"/>
</rule>
<rule ref="Squiz.Commenting.InlineComment"/>
<rule ref="Squiz.Commenting.LongConditionClosingComment"/>
<rule ref="Squiz.Commenting.PostStatementComment"/>
<rule ref="Squiz.Commenting.VariableComment"/>
<!-- Allow missing parameter documentation -->
<rule ref="Squiz.Commenting.FunctionComment">
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
</rule>
<rule ref="Squiz.Formatting.OperatorBracket"/>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing"/>
<rule ref="Squiz.Operators.ComparisonOperatorUsage">
<exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue"/>
<exclude name="Squiz.Operators.ComparisonOperatorUsage.NotAllowed"/>
</rule>
<!-- REMOVE THIS LINE TO ALLOW INLINE IF STATEMENTS -->
<!-- <rule ref="Squiz.PHP.DisallowInlineIf"/> -->
<rule ref="Squiz.Scope.MethodScope"/>
<rule ref="Squiz.Strings.ConcatenationSpacing"/>
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing"/>
<rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace"/>
<rule ref="Squiz.WhiteSpace.FunctionSpacing"/>
<rule ref="Squiz.WhiteSpace.MemberVarSpacing"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Commenting.Todo"/>
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
<rule ref="Generic.ControlStructures.InlineControlStructure">
<exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed"/>
</rule>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.LowerCaseKeyword"/>
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
<rule ref="PSR2.Classes.PropertyDeclaration"/>
<rule ref="PSR2.Methods.MethodDeclaration"/>
<rule ref="PSR2.Files.EndFileNewline"/>
<rule ref="PSR12.Files.OpenTag"/>
<rule ref="Zend.Files.ClosingTag"/>
<!-- Line length -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="120"/>
</properties>
<severity>0</severity>
</rule>
<!-- PEAR uses warnings for inline control structures, so switch back to errors -->
<rule ref="Generic.ControlStructures.InlineControlStructure">
<properties>
<property name="error" value="true"/>
</properties>
</rule>
<!-- We use custom indent rules for arrays -->
<rule ref="Generic.Arrays.ArrayIndent"/>
<rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
<severity>0</severity>
</rule>
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
<severity>0</severity>
</rule>
<!-- Check var names, but we don't want leading underscores for private vars -->
<!-- <rule ref="Squiz.NamingConventions.ValidVariableName"/> -->
<rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
<severity>0</severity>
</rule>
<!-- Only one argument per line in multi-line function calls -->
<rule ref="PEAR.Functions.FunctionCallSignature">
<properties>
<property name="allowMultipleArguments" value="false"/>
</properties>
</rule>
<!-- Have 12 chars padding maximum and always show as errors -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="maxPadding" value="12"/>
<property name="error" value="true"/>
</properties>
<!-- <severity>0</severity> -->
</rule>
<!-- Ban some functions -->
<!-- <rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="sizeof" value="count"/>
<element key="delete" value="unset"/>
<element key="print" value="echo"/>
<element key="is_null" value="null"/>
<element key="create_function" value="null"/>
</property>
</properties>
</rule> -->
<!-- Private methods MUST not be prefixed with an underscore -->
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<type>error</type>
</rule>
<!-- Private properties MUST not be prefixed with an underscore -->
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
<type>error</type>
</rule>
<!-- Function brackets -->
<!--
<rule ref="PSR2.Methods.FunctionClosingBrace"/>
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
-->
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman">
<severity>0</severity>
</rule>
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
</ruleset>
<!-- https://github.com/squizlabs/PHP_CodeSniffer/blob/master/phpcs.xml.dist -->
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.associations": {
"*.css": "css"
},
"editor.codeActionsOnSave": {
"source.fixAll.biome": "explicit",
"source.fixAll.stylelint": "explicit"
}
}
}
@philsinatra
Copy link
Author

If there are file association issues, add the following to the VSCode .workspace file:

"settings": {
    "files.associations": {
        "*.css": "css"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment