Skip to content

Commit 80fd80e

Browse files
committed
feat: update tailwind & eslint
1 parent 482075c commit 80fd80e

File tree

4 files changed

+165
-136
lines changed

4 files changed

+165
-136
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"error",
8686
{
8787
"beforeBlockComment": true,
88-
"afterBlockComment": true,
88+
"afterBlockComment": false,
8989
"beforeLineComment": true,
9090
"afterLineComment": false,
9191
"allowBlockStart": true,

phpcs.xml

Lines changed: 117 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,121 @@
11
<?xml version="1.0"?>
22
<ruleset name="WordPress Coding Standards for Plugins">
3-
<description>Generally-applicable sniffs for WordPress plugins</description>
4-
5-
<!--
6-
#############################################################################
7-
COMMAND LINE ARGUMENTS
8-
https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset
9-
#############################################################################
10-
-->
11-
12-
<file>.</file>
13-
14-
<!-- Only check PHP files. -->
15-
<arg name="extensions" value="php"/>
16-
17-
<!-- Show progress, show the error codes for each message (source). -->
18-
<arg value="ps"/>
19-
20-
<!-- Strip the filepaths down to the relevant bit. 加入這行就會失效了 -->
21-
<!-- <arg name="basepath" value="."/> -->
22-
23-
<!-- Check up to 8 files simultaneously. -->
24-
<arg name="parallel" value="8"/>
25-
26-
<rule ref="WordPress-Core">
27-
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag" />
28-
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_print_r" />
29-
</rule>
30-
<rule ref="WordPress-Docs">
31-
<exclude-pattern>*/tests/*</exclude-pattern>
32-
</rule>
33-
<rule ref="WordPress-Extra" />
34-
<rule ref="WordPress">
35-
<exclude name="WordPress.Files.FileName"/>
36-
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
37-
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
38-
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped"/>
39-
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket"/>
40-
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket"/>
41-
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis"/>
42-
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore"/>
43-
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter"/>
44-
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis"/>
45-
46-
</rule>
47-
48-
<exclude-pattern>./release/*</exclude-pattern>
49-
<exclude-pattern>*/node_modules/*</exclude-pattern>
50-
<exclude-pattern>*/vendor/*</exclude-pattern>
51-
<exclude-pattern>*/tests/*</exclude-pattern>
52-
<rule ref="Generic.WhiteSpace.ScopeIndent">
53-
<properties>
54-
<property name="indent" value="4" />
55-
<property name="exact" value="true" />
56-
<property name="tabIndent" value="true" />
57-
</properties>
58-
</rule>
59-
60-
<config name="testVersion" value="8.0-"/>
61-
<rule ref="PHPCompatibility" />
62-
63-
<!-- Enforce PSR1 compatible namespaces. -->
64-
<rule ref="PSR1.Classes.ClassDeclaration"/>
65-
66-
<!-- Enforce that classes are abstract or final. -->
67-
<rule ref="Universal.Classes.RequireFinalClass">
68-
<!-- ... with the exception of four sniffs which are known to be extended by external standards. -->
69-
<exclude-pattern>/WordPress/Sniffs/NamingConventions/ValidHookNameSniff\.php$</exclude-pattern>
70-
<exclude-pattern>/WordPress/Sniffs/Security/(EscapeOutput|NonceVerification|ValidatedSanitizedInput)Sniff\.php$</exclude-pattern>
71-
</rule>
72-
73-
<!-- Enforce that methods in traits are always final. -->
74-
<rule ref="Universal.FunctionDeclarations.RequireFinalMethodsInTraits"/>
75-
76-
<!--
77-
#############################################################################
78-
SNIFF SPECIFIC CONFIGURATION
79-
#############################################################################
80-
-->
81-
82-
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
83-
<properties>
84-
<property name="alignMultilineItems" value="!=100"/>
85-
<property name="exact" value="true" phpcs-only="true"/>
86-
</properties>
87-
</rule>
88-
89-
<!-- exclude Full-Stop comment style -->
90-
<rule ref="Squiz.Commenting.FunctionComment">
91-
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
92-
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
93-
</rule>
94-
95-
<!-- Allow short syntax arrays. -->
96-
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
97-
<rule ref="Universal.Arrays.DisallowShortArraySyntax.Found">
98-
<severity>0</severity>
99-
</rule>
100-
<!-- Disallow long array syntax -->
101-
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
102-
<exclude-pattern>*</exclude-pattern>
103-
</rule>
104-
105-
106-
<rule ref="Generic.Files.LineEndings">
107-
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
108-
</rule>
109-
110-
<!-- 允許單行 <?php. -->
111-
<rule ref="Squiz.PHP.EmbeddedPhp.ContentAfterOpen">
112-
<severity>0</severity>
113-
</rule>
114-
3+
<description>Generally-applicable sniffs for WordPress plugins</description>
4+
5+
<!--
6+
#############################################################################
7+
COMMAND LINE ARGUMENTS
8+
https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-Ruleset
9+
#############################################################################
10+
-->
11+
12+
<file>.</file>
13+
14+
<!-- Only check PHP files. -->
15+
<arg name="extensions" value="php"/>
16+
17+
<!-- Show progress, show the error codes for each message (source). -->
18+
<arg value="ps"/>
19+
20+
<!-- Strip the filepaths down to the relevant bit. 加入這行就會失效了 -->
21+
<!-- <arg name="basepath" value="."/> -->
22+
23+
<!-- Check up to 8 files simultaneously. -->
24+
<arg name="parallel" value="8"/>
25+
26+
<rule ref="WordPress-Core">
27+
<exclude name="Squiz.Commenting.FileComment.MissingPackageTag"/>
28+
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_print_r"/>
29+
</rule>
30+
<rule ref="WordPress-Docs">
31+
<exclude-pattern>*/tests/*</exclude-pattern>
32+
</rule>
33+
<rule ref="WordPress-Extra"/>
34+
<rule ref="WordPress">
35+
<exclude name="WordPress.Files.FileName"/>
36+
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
37+
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
38+
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped"/>
39+
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket"/>
40+
<exclude name="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket"/>
41+
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis"/>
42+
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore"/>
43+
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter"/>
44+
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis"/>
45+
<exclude name="WordPress.DateTime.RestrictedFunctions.date_date"/>
46+
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
47+
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
48+
</rule>
49+
50+
<exclude-pattern>.idea/*</exclude-pattern>
51+
<exclude-pattern>js/*</exclude-pattern>
52+
<exclude-pattern>./release/*</exclude-pattern>
53+
<exclude-pattern>*/node_modules/*</exclude-pattern>
54+
<exclude-pattern>*/vendor/*</exclude-pattern>
55+
<exclude-pattern>*/tests/*</exclude-pattern>
56+
<rule ref="Generic.WhiteSpace.ScopeIndent">
57+
<properties>
58+
<property name="indent" value="4"/>
59+
<property name="exact" value="true"/>
60+
<property name="tabIndent" value="true"/>
61+
</properties>
62+
</rule>
63+
64+
<config name="testVersion" value="8.0-"/>
65+
<rule ref="PHPCompatibility"/>
66+
67+
<!-- Enforce PSR1 compatible namespaces. -->
68+
<rule ref="PSR1.Classes.ClassDeclaration"/>
69+
70+
<!-- Enforce that classes are abstract or final. -->
71+
<rule ref="Universal.Classes.RequireFinalClass">
72+
<!-- ... with the exception of four sniffs which are known to be extended by external standards. -->
73+
<exclude-pattern>/WordPress/Sniffs/NamingConventions/ValidHookNameSniff\.php$</exclude-pattern>
74+
<exclude-pattern>
75+
/WordPress/Sniffs/Security/(EscapeOutput|NonceVerification|ValidatedSanitizedInput)Sniff\.php$
76+
</exclude-pattern>
77+
</rule>
78+
79+
<!-- Enforce that methods in traits are always final. -->
80+
<rule ref="Universal.FunctionDeclarations.RequireFinalMethodsInTraits"/>
81+
82+
<!--
83+
#############################################################################
84+
SNIFF SPECIFIC CONFIGURATION
85+
#############################################################################
86+
-->
87+
88+
<rule ref="WordPress.Arrays.MultipleStatementAlignment">
89+
<properties>
90+
<property name="alignMultilineItems" value="!=100"/>
91+
<property name="exact" value="true" phpcs-only="true"/>
92+
</properties>
93+
</rule>
94+
95+
<!-- exclude Full-Stop comment style -->
96+
<rule ref="Squiz.Commenting.FunctionComment">
97+
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
98+
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
99+
</rule>
100+
101+
<!-- Allow short syntax arrays. -->
102+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
103+
<rule ref="Universal.Arrays.DisallowShortArraySyntax.Found">
104+
<severity>0</severity>
105+
</rule>
106+
<!-- Disallow long array syntax -->
107+
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
108+
<exclude-pattern>*</exclude-pattern>
109+
</rule>
110+
111+
112+
<rule ref="Generic.Files.LineEndings">
113+
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
114+
</rule>
115+
116+
<!-- 允許單行 <?php. -->
117+
<rule ref="Squiz.PHP.EmbeddedPhp.ContentAfterOpen">
118+
<severity>0</severity>
119+
</rule>
115120

116121
</ruleset>

plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Tags: vite, react, tailwind, typescript, react-query, scss, WordPress, WordPress plugin
1616
*/
1717

18-
declare (strict_types = 1);
18+
declare ( strict_types=1 );
1919

2020
namespace J7\WpReactPlugin;
2121

@@ -54,7 +54,7 @@ public function __construct() {
5454
[
5555
'app_name' => 'My App',
5656
'github_repo' => 'https://github.com/j7-dev/wp-react-plugin',
57-
'callback' => [ '\J7\WpReactPlugin\Bootstrap', 'instance' ],
57+
'callback' => [ Bootstrap::class, 'instance' ],
5858
]
5959
);
6060
}

tailwind.config.cjs

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,49 @@
11
/** @type {import('tailwindcss').Config} */
22
// eslint-disable-next-line no-undef
33
module.exports = {
4-
important: true,
5-
corePlugins: {
6-
preflight: false,
7-
},
8-
content: ['./js/src/**/*.{js,ts,jsx,tsx}', './inc/**/*.php'],
9-
theme: {
10-
extend: {
11-
colors: {
12-
primary: '#1677ff',
13-
},
14-
screens: {
15-
sm: '576px', // iphone SE
16-
md: '810px', // ipad Portrait
17-
lg: '1080px', // ipad Landscape
18-
xl: '1280px', // mac air
19-
xxl: '1440px',
20-
},
21-
},
22-
},
23-
plugins: [],
24-
safelist: [],
4+
important: true,
5+
corePlugins: {
6+
preflight: false,
7+
},
8+
content: ['./js/src/**/*.{js,ts,jsx,tsx}', './inc/**/*.php'],
9+
theme: {
10+
extend: {
11+
colors: {
12+
primary: '#1677ff',
13+
},
14+
screens: {
15+
sm: '576px', // iphone SE
16+
md: '810px', // ipad Portrait
17+
lg: '1080px', // ipad Landscape
18+
xl: '1280px', // mac air
19+
xxl: '1440px',
20+
},
21+
},
22+
},
23+
plugins: [
24+
function ({ addUtilities }) {
25+
const newUtilities = {
26+
'.rtl': {
27+
direction: 'rtl',
28+
},
29+
30+
// 與 WordPress 衝突的 class
31+
'.tw-hidden': {
32+
display: 'none',
33+
},
34+
'.tw-column-1': {
35+
columnCount: 1,
36+
},
37+
'.tw-column-2': {
38+
columnCount: 2,
39+
},
40+
'.tw-fixed': {
41+
position: 'fixed',
42+
},
43+
}
44+
addUtilities(newUtilities, ['responsive', 'hover'])
45+
},
46+
],
47+
safelist: [],
48+
blocklist: ['fixed', 'columns-1', 'columns-2', 'hidden'],
2549
}

0 commit comments

Comments
 (0)