Skip to content

Commit e1f42b8

Browse files
committed
Lint files
1 parent 40493e8 commit e1f42b8

16 files changed

+47
-54
lines changed

packages/demo/src/templates/pages/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* @returns {Promise<object>}
3+
*/
14
export async function data() {
25
return {
36
head: {

packages/demo/src/templates/pages/posts/[slug].js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
*
3+
*/
14
export async function data({ slug } = {}) {
25
return {
36
bar: 'This is the default post data loader',

packages/demo/src/templates/pages/posts/bar.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { data as defaultData } from './[slug].js';
22

3+
/**
4+
*
5+
*/
36
export async function data({ slug } = {}) {
47
const mainData = await defaultData({ slug });
58
return {

packages/demo/src/templates/pages/posts/hello-world.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* @returns {Promise<{ foo: string[] }>}
3+
*/
14
export async function data() {
25
return {
36
foo: ['foo', 'buz'],

packages/preset-prototyping/src/index.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -148,27 +148,22 @@ export function prototyping(options) {
148148

149149
const extendTwig = typeof opts.twig.extend === 'function' ? opts.twig.extend : () => {};
150150
opts.twig.functions = {
151-
...(opts?.twig?.functions || {}),
152-
// eslint-disable-next-line camelcase
151+
...opts?.twig?.functions,
153152
html_styles(styles) {
154153
return Html.renderStyleAttribute(styles);
155154
},
156-
// eslint-disable-next-line camelcase
157155
html_attributes(attributes) {
158156
return Html.renderAttributes(attributes);
159157
},
160-
// eslint-disable-next-line camelcase
161158
html_classes(classes) {
162159
return Html.renderClass(classes);
163160
},
164-
// eslint-disable-next-line camelcase
165161
merge_html_attributes(attributes = {}, defaultAttributes = {}, requiredAttributes = {}) {
166162
return Html.mergeAttributes(attributes, defaultAttributes, requiredAttributes);
167163
},
168164
dump(...args) {
169165
return args.map((arg) => `<pre>${JSON.stringify(arg, null, 2)}</pre>`).join('\n');
170166
},
171-
// eslint-disable-next-line camelcase
172167
is_dev() {
173168
return isDev;
174169
},
@@ -298,9 +293,7 @@ export function prototyping(options) {
298293
cache: true,
299294
template: `${templatePath}?${params}`,
300295
templateParameters: {
301-
// eslint-disable-next-line camelcase
302296
updated_at: stats.mtime,
303-
// eslint-disable-next-line camelcase
304297
created_at: stats.birthtime,
305298
template: file,
306299
...Object.fromEntries(params.entries()),
@@ -366,9 +359,7 @@ export function prototyping(options) {
366359
cache: true,
367360
template: `${templatePath}?${params}`,
368361
templateParameters: {
369-
// eslint-disable-next-line camelcase
370362
created_at: stats.birthtime,
371-
// eslint-disable-next-line camelcase
372363
updated_at: stats.mtime,
373364
template: file,
374365
...Object.fromEntries(params.entries()),

packages/webpack-config/src/dev.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default async function dev(options = {}) {
1818
const server = await getServer(config);
1919

2020
const webpackBar = webpackConfig.plugins.find(
21-
(plugin) => plugin.constructor.name === 'WebpackBarPlugin'
21+
(plugin) => plugin.constructor.name === 'WebpackBarPlugin',
2222
);
2323

2424
let webpackBarHasRunOnce = false;
@@ -68,7 +68,7 @@ export default async function dev(options = {}) {
6868
Object.entries(webpackConfig.entry).map(([name, value]) => [
6969
name,
7070
['webpack-hot-middleware/client?reload=true', ...(Array.isArray(value) ? value : [value])],
71-
])
71+
]),
7272
);
7373

7474
const bundler = webpack(webpackConfig);
@@ -84,7 +84,7 @@ export default async function dev(options = {}) {
8484
assets: true,
8585
colors: true,
8686
excludeAssets: [/\.map$/, /hot-update/, /^manifest\.(js|json)$/],
87-
})
87+
}),
8888
);
8989
console.log('');
9090
console.log('');

packages/webpack-config/src/index.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const {
3838

3939
/**
4040
* Define the configuration.
41-
*
4241
* @template {import('./index').MetaConfig} T
4342
* @param {T} config
4443
* @returns {T}
@@ -49,13 +48,12 @@ export function defineConfig(config) {
4948

5049
/**
5150
* Get the generated Webpack configuration.
52-
*
53-
* @param {Object} options
51+
* @param {object} options
5452
* @param {'production'|'development'} [options.mode]
5553
* @returns {import('webpack').Configuration}
5654
*/
5755
export function getWebpackConfig({ mode = process.env.NODE_ENV } = {}) {
58-
const config = getMetaConfig({ target: [target] });
56+
const config = getMetaConfig({ mode });
5957
return mode === 'production' ? getWebpackProdConfig(config) : getWebpackDevConfig(config);
6058
}
6159

packages/webpack-config/src/presets/https.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function createCertificates() {
1616

1717
const cachePath = path.join(
1818
process.env.PWD,
19-
'node_modules/.cache/@studiometa/webpack-config/certificates/'
19+
'node_modules/.cache/@studiometa/webpack-config/certificates/',
2020
);
2121

2222
execSync(`mkdir -p ${cachePath}`);

packages/webpack-config/src/presets/tailwindcss.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ export default function tailwindcss(options = {}) {
2222
path: require.resolve('tailwindcss', { paths: [configPath] }),
2323
configViewerPath: '/_tailwind',
2424
},
25-
options
25+
options,
2626
);
2727

2828
if (isDev) {
2929
const { default: createServer } = await import('tailwind-config-viewer/server/index.js');
3030
await extendBrowsersync(config, async (bsConfig) => {
3131
const tailwindConfigViewerServer = createServer({
3232
tailwindConfigProvider: () =>
33-
// eslint-disable-next-line import/no-dynamic-require
3433
require(findUpSync(['tailwind.config.js', 'tailwind.config.cjs'])),
3534
}).asMiddleware();
3635

@@ -44,8 +43,8 @@ export default function tailwindcss(options = {}) {
4443
bsConfig.infos.push(
4544
(url) =>
4645
`Tailwind Viewer runnning at ${chalk.blue(
47-
withTrailingSlash(url + opts.configViewerPath)
48-
)}`
46+
withTrailingSlash(url + opts.configViewerPath),
47+
)}`,
4948
);
5049
});
5150
}
@@ -76,7 +75,7 @@ export default function tailwindcss(options = {}) {
7675
}
7776

7877
const postcssIndex = rule.use.findIndex(
79-
(use) => use === 'postcss-loader' || use.loader === 'postcss-loader'
78+
(use) => use === 'postcss-loader' || use.loader === 'postcss-loader',
8079
);
8180

8281
if (postcssIndex > -1) {

packages/webpack-config/src/presets/yaml.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default function yaml(options = {}) {
1212
{
1313
loaderOptions: {},
1414
},
15-
options
15+
options,
1616
);
1717

1818
return {

packages/webpack-config/src/utils/extend-browsersync-config.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
/**
88
* Extends the `server` configuration property.
9-
*
109
* @param {MetaConfig} config
1110
* @param {(config:BrowsersyncOptions, instance:BrowserSyncInstance)=> void} fn
1211
*/

packages/webpack-config/src/utils/extend-webpack-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
/**
77
* Extends the `webpack` configuration property.
8-
*
98
* @param {MetaConfig} config
109
* @param {(config:WebpackConfig, isDev: boolean) => Promise<void>} fn
1110
*/
1211
export default async function extendWebpackConfig(config, fn) {
12+
// eslint-disable-next-line no-empty-function
1313
const oldWebpackConfig = typeof config.webpack === 'function' ? config.webpack : () => {};
1414

1515
config.webpack = async (webpackConfig, isDev) => {

packages/webpack-config/src/utils/get-browsersync.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async function getConfig(metaConfig) {
5353
const [fileGlob, callback] = glob;
5454
if (typeof callback !== 'function') {
5555
throw new Error(
56-
'A watch item should implement the following schema: [glob:string, callback:function]'
56+
'A watch item should implement the following schema: [glob:string, callback:function]',
5757
);
5858
}
5959
instance.watch(fileGlob, { cwd: metaConfig.context }, (event, file) => {

packages/webpack-config/src/utils/get-config.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import extendWebpack from './extend-webpack-config.js';
55

66
/**
77
* Get config from meta.config.js file.
8-
*
98
* @param {{ analyze: boolean, mode: 'development'|'production' }} [options] CLI Options.
109
* @returns {import('../index').MetaConfig}
1110
*/
@@ -17,7 +16,7 @@ export default async function getConfig({ analyze = false, mode = 'production' }
1716
[
1817
'Could not find a config file.',
1918
'Is there a meta.config.js file up in the folder tree?',
20-
].join('\n')
19+
].join('\n'),
2120
);
2221
}
2322

@@ -45,25 +44,23 @@ export default async function getConfig({ analyze = false, mode = 'production' }
4544
if (Array.isArray(config.presets) && config.presets.length) {
4645
console.log('Applying presets...');
4746

48-
// eslint-disable-next-line no-restricted-syntax
4947
for (let preset of config.presets) {
5048
if (typeof preset === 'function') {
5149
preset = preset(isDev);
5250
}
5351

5452
if (!preset) {
55-
// eslint-disable-next-line no-continue
5653
continue;
5754
}
5855

5956
if (!preset.name && typeof preset.handler !== 'function') {
6057
console.log('Preset misconfigured.', preset);
61-
// eslint-disable-next-line no-continue
58+
6259
continue;
6360
}
6461

6562
const start = performance.now();
66-
// eslint-disable-next-line no-await-in-loop
63+
6764
await preset.handler(config, {
6865
extendBrowsersync,
6966
extendWebpack,

packages/webpack-config/src/utils/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Test if the given input has a trailing slash.
3-
* @param {string = ''} input The string to test.
3+
* @param {string} [input] The string to test.
44
* @returns {boolean}
55
*/
66
export function hasTrailingSlash(input = '') {
@@ -9,7 +9,7 @@ export function hasTrailingSlash(input = '') {
99

1010
/**
1111
* Make sure that a string does not end with a trailing slash.
12-
* @param {string = ''} input The string to test.
12+
* @param {string} [input] The string to test.
1313
* @returns {string} The string without trailing slash.
1414
*/
1515
export function withoutTrailingSlash(input = '') {
@@ -18,7 +18,7 @@ export function withoutTrailingSlash(input = '') {
1818

1919
/**
2020
* Make sure the string given ends with a trailing slash.
21-
* @param {string = ''} input The string to test.
21+
* @param {string} [input] The string to test.
2222
* @returns {string} The string with a trailing slash.
2323
*/
2424
export function withTrailingSlash(input = '') {
@@ -27,7 +27,7 @@ export function withTrailingSlash(input = '') {
2727

2828
/**
2929
* Test if the given input has a leading slash.
30-
* @param {string = ''} input The string to test.
30+
* @param {string} [input] The string to test.
3131
* @returns {boolean}
3232
*/
3333
export function hasLeadingSlash(input = '') {
@@ -36,7 +36,7 @@ export function hasLeadingSlash(input = '') {
3636

3737
/**
3838
* Make sure the given string does not have a leading slash.
39-
* @param {string = ''} input The string to test.
39+
* @param {string} [input] The string to test.
4040
* @returns {string} The string without leading slash.
4141
*/
4242
export function withoutLeadingSlash(input = '') {
@@ -45,8 +45,8 @@ export function withoutLeadingSlash(input = '') {
4545

4646
/**
4747
* Make sure the given string has a leading slash.
48-
* @param {string = ''} input The string to test.
49-
* @param {string} The string with a leading slash.
48+
* @param {string} [input] The string to test.
49+
* @returns {string} The string with a leading slash.
5050
*/
5151
export function withLeadingSlash(input = '') {
5252
return hasLeadingSlash(input) ? input : `/${input}`;

packages/webpack-config/src/webpack.base.config.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default async function getWebpackBaseConfig(config, { mode = 'production'
130130
loader: 'sass-loader',
131131
options: {
132132
sassOptions: {
133-
...(config.sassOptions ?? {}),
133+
...config.sassOptions,
134134
// This fix a strange bug where `url()` are not resolved
135135
// by Webpack when the output is set to `compressed` in
136136
// production mode.
@@ -205,20 +205,17 @@ export default async function getWebpackBaseConfig(config, { mode = 'production'
205205
entrypointsUseAssets: true,
206206
}),
207207
// Do not resolve URL starting with `/` in Sass and CSS files
208-
new ExternalsPlugin(
209-
'module',
210-
({ context, request, dependencyType, contextInfo }, callback) => {
211-
if (
212-
dependencyType === 'url' &&
213-
request.startsWith('/') &&
214-
CSS_FILE_REGEXP.test(contextInfo.issuer)
215-
) {
216-
return callback(null, `asset ${request}`);
217-
}
208+
new ExternalsPlugin('module', ({ request, dependencyType, contextInfo }, callback) => {
209+
if (
210+
dependencyType === 'url' &&
211+
request.startsWith('/') &&
212+
CSS_FILE_REGEXP.test(contextInfo.issuer)
213+
) {
214+
return callback(null, `asset ${request}`);
215+
}
218216

219-
callback();
220-
},
221-
),
217+
callback();
218+
}),
222219
],
223220
optimization: {
224221
minimizer: [

0 commit comments

Comments
 (0)