diff --git a/package.json b/package.json index 37d6483..e6c9434 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,7 @@ "version": "0.1.0", "private": true, "description": "Logo for Artichoke Ruby", - "keywords": [ - "programming language", - "scripting", - "ruby", - "rust", - "assets" - ], + "keywords": ["programming language", "scripting", "ruby", "rust", "assets"], "homepage": "https://github.com/artichoke/logo#readme", "bugs": "https://github.com/artichoke/logo/issues", "license": "MIT", @@ -50,9 +44,7 @@ "prettier-eslint": "^9.0.0" }, "babel": { - "presets": [ - "@babel/preset-env" - ] + "presets": ["@babel/preset-env"] }, "eslintConfig": { "env": { @@ -62,11 +54,7 @@ "node": true }, "parser": "babel-eslint", - "plugins": [ - "html", - "import", - "prettier" - ], + "plugins": ["html", "import", "prettier"], "extends": [ "airbnb", "prettier", diff --git a/scripts/format-text.sh b/scripts/format-text.sh index 1d34b67..50963ff 100755 --- a/scripts/format-text.sh +++ b/scripts/format-text.sh @@ -15,26 +15,36 @@ wrap() { fi } +parser() { + if [[ $1 == "js" ]]; then + echo "--parser babel" + elif [[ $1 == "md" ]]; then + echo "--parser markdown" + elif [[ $1 == "yml" ]]; then + echo "--parser yaml" + else + echo "--parser $1" + fi +} + format() { # shellcheck disable=SC2046 find . -type f \ -and -name "*.$1" \ - -and -not -path '*vendor*' \ - -and -not -path '*target*' \ - -and -not -path '*node_modules*' \ - -and -not -path '*spec/ruby*' -print0 | - xargs -0 yarn run prettier --write $(wrap "$1") + -and -not -path '*vendor/*/*' \ + -and -not -path '*target/*' \ + -and -not -path '*node_modules/*' -print0 | + xargs -0 yarn run prettier $(parser "$1") --write $(wrap "$1") } check() { # shellcheck disable=SC2046 find . -type f \ -and -name "*.$1" \ - -and -not -path '*vendor*' \ - -and -not -path '*target*' \ - -and -not -path '*node_modules*' \ - -and -not -path '*spec/ruby*' -print0 | - xargs -0 yarn run prettier --check $(wrap "$1") + -and -not -path '*vendor/*/*' \ + -and -not -path '*target/*' \ + -and -not -path '*node_modules/*' -print0 | + xargs -0 yarn run prettier $(parser "$1") --check $(wrap "$1") } if [[ $# -gt 1 && $1 == '--check' ]]; then diff --git a/scripts/lint.sh b/scripts/lint.sh index feed5ca..16b0c70 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -31,7 +31,7 @@ shfmt -f . | grep -v target/ | grep -v node_modules/ | grep -v spec-runner/spec/ ./scripts/format-text.sh --format "yaml" ./scripts/format-text.sh --format "yml" ## Lint with eslint -yarn run eslint --fix --ext .html,.js . +# yarn run eslint --fix --ext .html,.js . # Text sources diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index fd68d45..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,92 +0,0 @@ -const path = require("path"); -const HtmlWebPackPlugin = require("html-webpack-plugin"); -const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin"); -const TerserPlugin = require("terser-webpack-plugin"); -const MiniCssExtractPlugin = require("mini-css-extract-plugin"); -const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); - -const plugins = [ - new MiniCssExtractPlugin({ - filename: "[name].css", - chunkFilename: "[id].css" - }), - new HtmlWebPackPlugin({ - template: "index.html", - filename: "index.html", - minify: { - collapseWhitespace: true, - minifyCSS: true, - minifyJS: true, - removeComments: true, - useShortDoctype: true - } - }), - new HtmlWebpackInlineSourcePlugin() -]; - -module.exports = (env, argv) => { - let target = "debug"; - let cssLoader = "style-loader"; - if (argv.mode === "production") { - target = "release"; - cssLoader = MiniCssExtractPlugin.loader; - } - return { - context: path.resolve(__dirname, "artichoke-wasm/src"), - resolve: { - alias: { - "artichoke-wasm": path.resolve( - __dirname, - `target/wasm32-unknown-emscripten/${target}` - ) - } - }, - entry: path.resolve(__dirname, "artichoke-wasm/src/playground.js"), - output: { - path: path.resolve(__dirname, `target/webpack/${target}`) - }, - module: { - rules: [ - { - test: /\.jsx?$/, - exclude: /node_modules/, - use: { - loader: "babel-loader" - } - }, - { - test: /\.css$/, - use: [cssLoader, "css-loader"] - }, - { - test: /\.(jpe?g|png|gif)$/, - use: ["url-loader", "image-webpack-loader"] - }, - { - test: /\.svg$/, - use: ["svg-url-loader", "svgo-loader"] - }, - { - test: /-wasm\.js$/, - use: ["uglify-loader", "script-loader"] - }, - { - test: /\.wasm$/, - type: "javascript/auto", - use: [ - { - loader: "file-loader", - options: { - name: "[name].[ext]" - } - } - ] - } - ] - }, - plugins, - optimization: { - minimizer: [new TerserPlugin(), new OptimizeCSSAssetsPlugin()] - } - }; -};