Skip to content

Commit

Permalink
Lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Aug 31, 2021
1 parent 9a96c2c commit 96be692
Show file tree
Hide file tree
Showing 13 changed files with 1,976 additions and 1,638 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
extends: '@studiometa/eslint-config',
rules: {
'global-require': 'off',
'import/extensions': ['error', 'always', { ignorePackages: false }],
},
overrides: [
{
Expand Down
3,541 changes: 1,930 additions & 1,611 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@
"name": "@studiometa/webpack-config-root",
"version": "2.9.3",
"private": true,
"type": "module",
"type": "commonjs",
"workspaces": [
"packages/*"
]
],
"scripts": {
"lint": "eslint packages/webpack-config/src packages/demo/src --ext=.js,.vue",
"fix": "npm run lint -- --fix"
},
"devDependencies": {
"@studiometa/eslint-config": "^2.1.3",
"@studiometa/prettier-config": "^2.0.1",
"eslint": "^7.32.0",
"prettier": "^2.3.2"
}
}
3 changes: 3 additions & 0 deletions packages/demo/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
root: true,
extends: ['@studiometa/eslint-config'],
rules: {
'import/extensions': ['error', 'always', { ignorePackages: false }],
},
settings: {
'import/resolver': 'webpack',
},
Expand Down
3 changes: 3 additions & 0 deletions packages/demo/.stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: '@studiometa/stylelint-config',
};
2 changes: 1 addition & 1 deletion packages/demo/meta.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
module.exports = {
presets: ['prototyping', 'yaml'],
// Exclude the `test.scss` file from the merge
mergeCSS: /^(?!.*css\/test\.scss).*$/,
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@studiometa/webpack-config-demo",
"version": "2.9.3",
"private": true,
"type": "module",
"type": "commonjs",
"scripts": {
"dev": "node ../webpack-config/bin/cli.js dev",
"build": "node ../webpack-config/bin/cli.js build"
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class App extends Base {
refs: ['content', 'vue'],
...config,
components: {
Component: () => import('./components/Component'),
Component: () => import('./components/Component.js'),
},
};

Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/js/components/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class Component extends Base {
static config = {
name: 'Component',
components: {
ComponentFoo: () => import('../foo/Component'),
ComponentFoo: () => import('../foo/Component.js'),
},
};
}
8 changes: 4 additions & 4 deletions packages/webpack-config/src/presets/tailwindcss.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import merge from 'lodash.merge';
import findUp from 'find-up';
import { findUpSync } from 'find-up';
import chalk from 'chalk';
import createServer from 'tailwind-config-viewer/server/index.js';
import { createRequire } from 'module';
Expand All @@ -23,8 +23,9 @@ export default async (config, options = {}) => {
if (process.env.NODE_ENV === 'development') {
await extendBrowserSyncConfig(config, async (bsConfig) => {
const tailwindConfigViewerServer = createServer({
// eslint-disable-next-line import/no-dynamic-require
tailwindConfigProvider: () => require(findUp.sync('tailwind.config.js')),
tailwindConfigProvider: () =>
// eslint-disable-next-line import/no-dynamic-require
require(findUpSync(['tailwind.config.js', 'tailwind.config.cjs'])),
}).asMiddleware();

bsConfig.middleware = bsConfig.middleware || [];
Expand Down Expand Up @@ -78,4 +79,3 @@ export default async (config, options = {}) => {
});
});
};

32 changes: 17 additions & 15 deletions packages/webpack-config/src/utils/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ export default async (options) => {
if (Array.isArray(config.presets) && config.presets.length) {
console.log('Applying presets...');

await Promise.all(config.presets.map(async (preset) => {
const name = Array.isArray(preset) ? preset[0] : preset;
const opts = Array.isArray(preset) ? preset[1] : {};
const presetPathInfo = new URL(`../presets/${name}.js`, import.meta.url);

if (!fs.existsSync(presetPathInfo.pathname)) {
console.error(`The "${name}" preset is not available.`);
return;
}

console.log(`Using the "${name}" preset.`);

const { default: presetHandler } = await import(presetPathInfo.pathname);
await presetHandler(config, opts);
}));
await Promise.all(
config.presets.map(async (preset) => {
const name = Array.isArray(preset) ? preset[0] : preset;
const opts = Array.isArray(preset) ? preset[1] : {};
const presetPathInfo = new URL(`../presets/${name}.js`, import.meta.url);

if (!fs.existsSync(presetPathInfo.pathname)) {
console.error(`The "${name}" preset is not available.`);
return;
}

console.log(`Using the "${name}" preset.`);

const { default: presetHandler } = await import(presetPathInfo.pathname);
await presetHandler(config, opts);
})
);
}

return config;
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-config/src/webpack.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import WebpackAssetsManifest from 'webpack-assets-manifest';
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';

const { DefinePlugin } = webpack;
const { BundleAnalyzerPlugin} = BundleAnalyzerPluginImport;
const { BundleAnalyzerPlugin } = BundleAnalyzerPluginImport;

dotenv.config();

Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-config/src/webpack.prod.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import webpackMerge from 'webpack-merge';
import getWebpackConfig from './webpack.base.config.js'
import getWebpackConfig from './webpack.base.config.js';

export default async (config) => {
const baseConfig = await getWebpackConfig(config);
Expand Down

0 comments on commit 96be692

Please sign in to comment.