Skip to content

Instantly share code, notes, and snippets.

@tooinfinity
Last active January 6, 2025 20:30
Show Gist options
  • Select an option

  • Save tooinfinity/5cb71de40b063490b8039deaa38883e8 to your computer and use it in GitHub Desktop.

Select an option

Save tooinfinity/5cb71de40b063490b8039deaa38883e8 to your computer and use it in GitHub Desktop.
New project laravel configuration
.New project laravel configuration
/node_modules
/public
/build
{
"printWidth": 80,
"semi": true,
"singleQuote": true,
"tsxSingleQuote": true,
"bracketSpacing": true,
"tabWidth": 2,
"trailingComma": "es5",
"arrowParens": "avoid"
}

New project laravel configuration

Packages that i use we need to install it

Rector

  composer require rector/rector --dev

Laravel Pint

  composer require laravel/pint --dev

Prettier

  npm install --save-dev --save-exact prettier

ESlint

  npm init @eslint/config@latest

Laravel PHPStan

  composer require larastan/larastan --dev 

after install it copy and paste the config from this files

import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginReact from "eslint-plugin-react";
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import path from "node:path";
/** @type {import('eslint').Linter.Config[]} */
export default [
{ignores: ["build", "node_modules", "public", "resources/js/components/ui"]},
{ files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] },
{ languageOptions: {
globals: globals.browser,
ecmaVersion: 2022,
sourceType: "module",
parser:"@typescript-eslint/parser",
parserOptions:{
ecmaFeatures: {
jsx: true,
},
tsconfigRootDir: path.resolve(),
project: ["tsconfig.json"],
}
}
},
eslintPluginPrettierRecommended,
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
{
settings: {
react: {
version: "detect", // Automatically detect the React version
},
},
rules: {
"react/react-in-jsx-scope": "off", // React 17+ doesn't require import React
"react/prop-types": "off", // Disable prop-types if using TypeScript
// Prettier integration
"prettier/prettier": "error",
// TypeScript rules
"@typescript-eslint/no-unused-vars": "warn", // Unused variables in TS
"@typescript-eslint/explicit-module-boundary-types": "off",
},
},
];
includes:
- vendor/larastan/larastan/extension.neon
- vendor/nesbot/carbon/extension.neon
parameters:
paths:
- app/
- config/
- bootstrap/
- database/factories/
- routes/
# Level 10 is the highest level
level: 5
treatPhpDocTypesAsCertain: false
# excludePaths:
# - ./*/*/FileToBeExcluded.php
{
"preset": "laravel",
"rules": {
"array_push": true,
"backtick_to_shell_exec": true,
"date_time_immutable": true,
"declare_strict_types": true,
"lowercase_keywords": true,
"lowercase_static_reference": true,
"final_class": true,
"final_internal_class": true,
"final_public_method_for_abstract_class": true,
"fully_qualified_strict_types": true,
"global_namespace_import": {
"import_classes": true,
"import_constants": true,
"import_functions": true
},
"mb_str_functions": true,
"modernize_types_casting": true,
"new_with_parentheses": false,
"no_superfluous_elseif": true,
"no_useless_else": true,
"no_multiple_statements_per_line": true,
"ordered_class_elements": {
"order": [
"use_trait",
"case",
"constant",
"constant_public",
"constant_protected",
"constant_private",
"property_public",
"property_protected",
"property_private",
"construct",
"destruct",
"magic",
"phpunit",
"method_abstract",
"method_public_static",
"method_public",
"method_protected_static",
"method_protected",
"method_private_static",
"method_private"
],
"sort_algorithm": "none"
},
"ordered_interfaces": true,
"ordered_traits": true,
"protected_to_private": true,
"self_accessor": true,
"self_static_accessor": true,
"strict_comparison": true,
"visibility_required": true
}
}
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
return RectorConfig::configure()
->withPaths([
__DIR__.'/app',
__DIR__.'/bootstrap/app.php',
__DIR__.'/config',
__DIR__.'/database',
__DIR__.'/public',
])
->withSkip([
AddOverrideAttributeToOverriddenMethodsRector::class,
])
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
privatization: true,
earlyReturn: true,
strictBooleans: true,
)
->withPhpSets();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment