sdc-build-wp 4.6.1 → 4.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/eslint.config.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import { defineConfig } from 'eslint/config';
2
+ import stylistic from '@stylistic/eslint-plugin';
2
3
 
3
4
  export default defineConfig([
4
5
  {
6
+ plugins: {
7
+ '@stylistic': stylistic
8
+ },
5
9
  languageOptions: {
6
10
  parserOptions: {
7
11
  ecmaVersion: 'latest',
@@ -19,7 +23,8 @@ export default defineConfig([
19
23
  {
20
24
  max: 1
21
25
  }
22
- ]
26
+ ],
27
+ '@stylistic/quotes': [1, 'single']
23
28
  }
24
29
  }
25
30
  ]);
@@ -87,7 +87,10 @@ export default class BlocksComponent extends BaseComponent {
87
87
  ...this.project.chokidarOpts
88
88
  }).on('all', (event, path) => {
89
89
  if (!['unlink', 'unlinkDir'].includes(event)) {
90
- this.process(path);
90
+ if (path.endsWith('.js')) {
91
+ this.project.components.scripts.lint(path);
92
+ }
93
+ this.process(block);
91
94
  }
92
95
  });
93
96
  }
@@ -28,16 +28,10 @@ export default class ScriptsComponent extends BaseComponent {
28
28
  this.start();
29
29
 
30
30
  try {
31
- const eslint = new ESLint({
32
- fix: true,
33
- overrideConfigFile: true,
34
- overrideConfig: eslintConfig.default[0]
35
- });
36
- const lintresults = await eslint.lintFiles(options.entriesToLint || [entry]);
37
- await ESLint.outputFixes(lintresults);
38
- const formatter = await eslint.loadFormatter('stylish');
39
- const formatterOutput = formatter.format(lintresults);
40
- if (formatterOutput) { console.log(formatterOutput.replace(`${this.project.path}/${this.project.paths.src.src}/${this.project.paths.src.scripts}/`, '')); }
31
+ let thisLint = await this.lint(entry, options);
32
+ if (thisLint instanceof Error) {
33
+ throw thisLint;
34
+ }
41
35
  } catch (error) {
42
36
  console.log(error);
43
37
  this.log('error', `Failed linting ${entry.replace(`${this.project.path}/${this.project.paths.src.src}/${this.project.paths.src.scripts}/`, '')} - See above error.`);
@@ -70,7 +64,7 @@ export default class ScriptsComponent extends BaseComponent {
70
64
  }
71
65
 
72
66
  async process() {
73
- const promisesScripts = this.files.map((block, index) => this.build(block.file, { entriesToLint: index == 0 ? this.globs : null }));
67
+ const promisesScripts = this.files.map((group, index) => this.build(group.file, { entriesToLint: index == 0 ? this.globs : null }));
74
68
  await Promise.all(promisesScripts);
75
69
  }
76
70
 
@@ -82,4 +76,22 @@ export default class ScriptsComponent extends BaseComponent {
82
76
  });
83
77
  }
84
78
 
79
+ async lint(entry, options) {
80
+ try {
81
+ const eslint = new ESLint({
82
+ fix: true,
83
+ overrideConfigFile: true,
84
+ overrideConfig: eslintConfig.default[0]
85
+ });
86
+ const lintresults = await eslint.lintFiles(options?.entriesToLint || [entry]);
87
+ await ESLint.outputFixes(lintresults);
88
+ const formatter = await eslint.loadFormatter('stylish');
89
+ const formatterOutput = formatter.format(lintresults);
90
+ if (formatterOutput) { console.log(formatterOutput.replace(`${this.project.path}/${this.project.paths.src.src}/${this.project.paths.src.scripts}/`, '')); }
91
+ return true;
92
+ } catch (error) {
93
+ return error;
94
+ }
95
+ }
96
+
85
97
  }
@@ -160,13 +160,13 @@ export default class StyleComponent extends BaseComponent {
160
160
  await this.buildTheme();
161
161
  }
162
162
  let i = 0;
163
- for (var block of this.files) {
164
- if (!entry || entry == block.file) {
165
- await this.build(block.file, {
166
- name: block.name,
163
+ for (let group of this.files) {
164
+ if (!entry || entry == group.file) {
165
+ await this.build(group.file, {
166
+ name: group.name,
167
167
  entriesToLint: i == 0 ? this.globs : null
168
168
  });
169
- if (entry == block.file) {
169
+ if (entry == group.file) {
170
170
  break;
171
171
  }
172
172
  i++;
@@ -182,9 +182,9 @@ export default class StyleComponent extends BaseComponent {
182
182
  ...this.project.chokidarOpts
183
183
  }).on('all', (event, path) => {
184
184
  let hasRanSingle = false;
185
- for (var block of this.files) {
186
- if (path == block.file || this.utils.getImportedSASSFiles(block.file).includes(path)) {
187
- this.process(block.file, { buildTheme: path == this.project.paths.theme.json });
185
+ for (let group of this.files) {
186
+ if (path == group.file || this.utils.getImportedSASSFiles(group.file).includes(path)) {
187
+ this.process(group.file, { buildTheme: path == this.project.paths.theme.json });
188
188
  hasRanSingle = true;
189
189
  }
190
190
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "4.6.1",
3
+ "version": "4.6.3",
4
4
  "description": "Custom WordPress build process.",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -22,6 +22,7 @@
22
22
  "sdc-build-wp": "./index.js"
23
23
  },
24
24
  "dependencies": {
25
+ "@stylistic/eslint-plugin": "^5.2.2",
25
26
  "@stylistic/stylelint-plugin": "^4.0.0",
26
27
  "@typescript-eslint/eslint-plugin": "^8.38.0",
27
28
  "@typescript-eslint/parser": "^8.38.0",