Search code examples
laraveleditorconfig

.editorconfig folder-specific configuration


I have a Laravel 5.8 project and my .editorconfig setup is based on PHP coding (with 4 spaces) and some other considerations. What I want to know if there is a way to set up a folder-specific configuration for my resources/js in order to adapt different coding rules (like 2 spaces).

Also, is there a way to setup eslint in this project to also lint my js code without any trouble?

Thanks in advance!


Solution

  • As far as I know, you can specify a path within the section name's square brackets:

    # Rules specified in this section matching all files
    [*]
    end_of_line = lf
    insert_final_newline = true
    
    [*.php]
    indent_style = space
    indent_size = 4
    
    # Rules in here only match .js files inside your resources/js folder.
    [resources/js/**.js]
    indent_style = space
    indent_size = 2
    

    Read more on the main page of editorconfig.org.