@@ -57,7 +57,8 @@ user@machine repo % mvn spotless:check
57
57
- [ Sql] ( #sql ) ([ dbeaver] ( #dbeaver ) )
58
58
- [ Maven Pom] ( #maven-pom ) ([ sortPom] ( #sortpom ) )
59
59
- [ Markdown] ( #markdown ) ([ flexmark] ( #flexmark ) )
60
- - [ Typescript] ( #typescript ) ([ tsfmt] ( #tsfmt ) , [ prettier] ( #prettier ) )
60
+ - [ Typescript] ( #typescript ) ([ tsfmt] ( #tsfmt ) , [ prettier] ( #prettier ) , [ ESLint] ( #eslint--typescript- ) )
61
+ - [ Javascript] ( #javascript ) ([ prettier] ( #prettier ) , [ ESLint] ( #eslint--javascript- ) )
61
62
- Multiple languages
62
63
- [ Prettier] ( #prettier ) ([ plugins] ( #prettier-plugins ) , [ npm detection] ( #npm-detection ) , [ ` .npmrc ` detection] ( #npmrc-detection ) )
63
64
- [ eclipse web tools platform] ( #eclipse-web-tools-platform )
@@ -660,6 +661,7 @@ Currently, none of the available options can be configured yet. It uses only the
660
661
661
662
<tsfmt /> <!-- has its own section below -->
662
663
<prettier /> <!-- has its own section below -->
664
+ <eslint /> <!-- has its own section below -->
663
665
664
666
<licenseHeader >
665
667
<content >/* (C)$YEAR */</content > <!-- or <file>${project.basedir}/license-header</file> -->
@@ -700,8 +702,144 @@ The auto-discovery of config files (up the file tree) will not work when using t
700
702
701
703
For details, see the [ npm detection] ( #npm-detection ) and [ ` .npmrc ` detection] ( #npmrc-detection ) sections of prettier, which apply also to tsfmt.
702
704
705
+ ### ESLint (typescript)
706
+
707
+ [ npm] ( https://www.npmjs.com/package/eslint ) . [ changelog] ( https://github.com/eslint/eslint/blob/main/CHANGELOG.md ) . * Please note:*
708
+ The auto-discovery of config files (up the file tree) will not work when using ESLint within spotless,
709
+ hence you are required to provide resolvable file paths for config files, or alternatively provide the configuration inline.
710
+
711
+ The configuration is very similar to the [ ESLint (Javascript)] ( #eslint--javascript- ) configuration. It differs in supported
712
+ styleguides and the requirement for a tsconfigFile.
713
+
714
+ ``` xml
715
+ <eslint >
716
+ <!-- Specify at most one of the following 3 configs: either 'eslintVersion', 'devDependencies' or 'devDependencyProperties' -->
717
+ <eslintVersion >8.30.0</eslintVersion >
718
+ <devDependencies >
719
+ <myEslintFork >8.30.0</myEslintFork >
720
+ <myEslintPlugin >1.2.1</myEslintPlugin >
721
+ </devDependencies >
722
+ <devDependencyProperties >
723
+ <property >
724
+ <name >eslint</name >
725
+ <value >8.30.0</value >
726
+ </property >
727
+ <property >
728
+ <name >@eslint/my-plugin-typescript</name > <!-- this could not be written in the simpler to write 'devDependencies' element. -->
729
+ <value >0.14.2</value >
730
+ </property >
731
+ </devDependencyProperties >
732
+ <!-- optional: use one of the popular style guides: 'standard-with-typescript' or 'xo-typescript' -->
733
+ <styleGuide >standard-with-typescript</styleGuide >
734
+ <!-- mandatory: provide either a configFile or a configJs object -->
735
+ <configFile >${project.basedir}/.eslintrc.js</configFile >
736
+ <configJs >
737
+ {
738
+ env: {
739
+ browser: true,
740
+ es2021: true
741
+ },
742
+ extends: 'standard-with-typescript',
743
+ overrides: [
744
+ ],
745
+ parserOptions: {
746
+ ecmaVersion: 'latest',
747
+ sourceType: 'module',
748
+ project: './tsconfig.json',
749
+ },
750
+ rules: {
751
+ }
752
+ }
753
+ </configJs >
754
+ <!-- recommended: provide a tsconfigFile - especially when using the styleguides -->
755
+ <tsconfigFile >${project.basedir}/tsconfig.json</tsconfigFile >
756
+ </eslint >
757
+ ```
758
+
759
+ ** Prerequisite: ESLint requires a working NodeJS version**
760
+
761
+ For details, see the [ npm detection] ( #npm-detection ) and [ ` .npmrc ` detection] ( #npmrc-detection ) sections of prettier, which apply also to ESLint.
762
+
703
763
<a name =" applying-prettier-to-javascript--flow--typescript--css--scss--less--jsx--graphql--yaml--etc " ></a >
704
764
765
+ ## Javascript
766
+
767
+ [ code] ( https://github.com/diffplug/spotless/blob/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/javascript/Javascript.java ) . [ available steps] ( https://github.com/diffplug/spotless/tree/main/plugin-maven/src/main/java/com/diffplug/spotless/maven/javascript ) .
768
+
769
+ ``` xml
770
+ <configuration >
771
+ <typescript >
772
+ <includes > <!-- You have to set the target manually -->
773
+ <include >src/**/*.js</include >
774
+ </includes >
775
+
776
+ <prettier /> <!-- has its own section below -->
777
+ <eslint /> <!-- has its own section below -->
778
+
779
+ <licenseHeader >
780
+ <content >/* (C)$YEAR */</content > <!-- or <file>${project.basedir}/license-header</file> -->
781
+ <delimiter >REGEX_TO_DEFINE_TOP_OF_FILE</delimiter > <!-- set a regex to define the top of the file -->
782
+ </licenseHeader >
783
+ </typescript >
784
+ </configuration >
785
+ ```
786
+
787
+
788
+ ### ESLint (Javascript)
789
+
790
+ [ npm] ( https://www.npmjs.com/package/eslint ) . [ changelog] ( https://github.com/eslint/eslint/blob/main/CHANGELOG.md ) . * Please note:*
791
+ The auto-discovery of config files (up the file tree) will not work when using ESLint within spotless,
792
+ hence you are required to provide resolvable file paths for config files, or alternatively provide the configuration inline.
793
+
794
+ The configuration is very similar to the [ ESLint (Typescript)] ( #eslint--typescript- ) configuration. It differs in supported
795
+ styleguides and no requirement for a tsconfig (of course).
796
+
797
+ ``` xml
798
+ <eslint >
799
+ <!-- Specify at most one of the following 3 configs: either 'eslintVersion', 'devDependencies' or 'devDependencyProperties' -->
800
+ <eslintVersion >8.30.0</eslintVersion >
801
+ <devDependencies >
802
+ <myEslintFork >8.30.0</myEslintFork >
803
+ <myEslintPlugin >1.2.1</myEslintPlugin >
804
+ </devDependencies >
805
+ <devDependencyProperties >
806
+ <property >
807
+ <name >eslint</name >
808
+ <value >8.30.0</value >
809
+ </property >
810
+ <property >
811
+ <name >@eslint/my-plugin-javascript</name > <!-- this could not be written in the simpler to write 'devDependencies' element. -->
812
+ <value >0.14.2</value >
813
+ </property >
814
+ </devDependencyProperties >
815
+ <!-- optional: use one of the popular style guides: 'standard', 'airbnb', 'google' or 'xo' -->
816
+ <styleGuide >standard</styleGuide >
817
+ <!-- mandatory: provide either a configFile or a configJs object -->
818
+ <configFile >${project.basedir}/.eslintrc.js</configFile >
819
+ <configJs >
820
+ {
821
+ env: {
822
+ browser: true,
823
+ es2021: true
824
+ },
825
+ extends: 'standard',
826
+ overrides: [
827
+ ],
828
+ parserOptions: {
829
+ ecmaVersion: 'latest',
830
+ sourceType: 'module'
831
+ },
832
+ rules: {
833
+ }
834
+ }
835
+ </configJs >
836
+ </eslint >
837
+ ```
838
+
839
+ ** Prerequisite: ESLint requires a working NodeJS version**
840
+
841
+ For details, see the [ npm detection] ( #npm-detection ) and [ ` .npmrc ` detection] ( #npmrc-detection ) sections of prettier, which apply also to ESLint.
842
+
705
843
## Prettier
706
844
707
845
[ homepage] ( https://prettier.io/ ) . [ changelog] ( https://github.com/prettier/prettier/blob/master/CHANGELOG.md ) . [ official plugins] ( https://prettier.io/docs/en/plugins.html#official-plugins ) . [ community plugins] ( https://prettier.io/docs/en/plugins.html#community-plugins ) . Prettier is a formatter that can format almost every anything - JavaScript, JSX, Angular, Vue, Flow, TypeScript, CSS, Less, SCSS, HTML, JSON, GraphQL, Markdown (including GFM and MDX), and YAML. It can format even more [ using plugins] ( https://prettier.io/docs/en/plugins.html ) (PHP, Ruby, Swift, XML, Apex, Elm, Java (!!), Kotlin, pgSQL, .properties, solidity, svelte, toml, shellscript, ...).
0 commit comments