Skip to content

Commit

Permalink
style: use default prettier options (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait authored Dec 4, 2020
1 parent 80dbf18 commit 9600af0
Show file tree
Hide file tree
Showing 29 changed files with 676 additions and 677 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
root: true,
extends: ['@webpack-contrib/eslint-config-webpack', 'prettier'],
extends: ["@webpack-contrib/eslint-config-webpack", "prettier"],
};
1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Then add the plugin to your `webpack` config. For example:
**file.js**

```js
import css from 'file.css';
import css from "file.css";
```

**webpack.config.js**
Expand All @@ -40,8 +40,8 @@ module.exports = {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
enforce: "pre",
use: ["source-map-loader"],
},
],
},
Expand Down Expand Up @@ -87,18 +87,18 @@ module.exports = {
rules: [
{
test: /\.js$/,
enforce: 'pre',
enforce: "pre",
use: [
{
loader: 'source-map-loader',
loader: "source-map-loader",
options: {
filterSourceMappingUrl: (url, resourcePath) => {
if (/broker-source-map-url\.js$/i.test(url)) {
return false;
}

if (/keep-source-mapping-url\.js$/i.test(resourcePath)) {
return 'skip';
return "skip";
}

return true;
Expand Down Expand Up @@ -126,8 +126,8 @@ module.exports = {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
enforce: "pre",
use: ["source-map-loader"],
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module.exports = (api) => {
return {
presets: [
[
'@babel/preset-env',
"@babel/preset-env",
{
targets: {
node: '10.13.0',
node: "10.13.0",
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
extends: ["@commitlint/config-conventional"],
};
4 changes: 2 additions & 2 deletions husky.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
hooks: {
'pre-commit': 'lint-staged',
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
},
};
4 changes: 2 additions & 2 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'*.js': ['prettier --write', 'eslint --fix'],
'*.{json,md,yml,css,ts}': ['prettier --write'],
"*.js": ["eslint --fix", "prettier --write"],
"*.{json,md,yml,css,ts}": ["prettier --write"],
};
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@
"whatwg-mimetype": "^2.3.0"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@babel/cli": "^7.12.8",
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@webpack-contrib/defaults": "^6.3.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^26.6.1",
"cross-env": "^7.0.2",
"babel-jest": "^26.6.3",
"cross-env": "^7.0.3",
"del": "^6.0.0",
"del-cli": "^3.0.1",
"eslint": "^7.12.0",
"eslint-config-prettier": "^6.14.0",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"husky": "^4.3.0",
"jest": "^26.6.1",
"lint-staged": "^10.4.2",
"jest": "^26.6.3",
"lint-staged": "^10.5.2",
"memfs": "^3.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"prettier": "^2.2.1",
"standard-version": "^9.0.0",
"webpack": "^5.9.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/cjs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const loader = require('./index');
const loader = require("./index");

module.exports = loader.default;
module.exports.raw = loader.raw;
36 changes: 18 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
import path from 'path';
import path from "path";

import { getOptions } from 'loader-utils';
import { validate } from 'schema-utils';
import { getOptions } from "loader-utils";
import { validate } from "schema-utils";

import schema from './options.json';
import { getSourceMappingURL, fetchFromURL, flattenSourceMap } from './utils';
import schema from "./options.json";
import { getSourceMappingURL, fetchFromURL, flattenSourceMap } from "./utils";

export default async function loader(input, inputMap) {
const options = getOptions(this);

validate(schema, options, {
name: 'Source Map Loader',
baseDataPath: 'options',
name: "Source Map Loader",
baseDataPath: "options",
});

const { sourceMappingURL, replacementString } = getSourceMappingURL(input);
Expand All @@ -32,9 +32,9 @@ export default async function loader(input, inputMap) {

try {
behaviourSourceMappingUrl =
typeof options.filterSourceMappingUrl !== 'undefined'
typeof options.filterSourceMappingUrl !== "undefined"
? options.filterSourceMappingUrl(sourceMappingURL, this.resourcePath)
: 'consume';
: "consume";
} catch (error) {
callback(error);

Expand All @@ -43,12 +43,12 @@ export default async function loader(input, inputMap) {

// eslint-disable-next-line default-case
switch (behaviourSourceMappingUrl) {
case 'skip':
case "skip":
callback(null, input, inputMap);
return;
case false:
case 'remove':
callback(null, input.replace(replacementString, ''), inputMap);
case "remove":
callback(null, input.replace(replacementString, ""), inputMap);
return;
}

Expand Down Expand Up @@ -76,7 +76,7 @@ export default async function loader(input, inputMap) {
let map;

try {
map = JSON.parse(sourceContent.replace(/^\)\]\}'/, ''));
map = JSON.parse(sourceContent.replace(/^\)\]\}'/, ""));
} catch (parseError) {
this.emitWarning(
new Error(
Expand Down Expand Up @@ -104,11 +104,11 @@ export default async function loader(input, inputMap) {
let sourceContent;

const originalSourceContent =
map.sourcesContent && typeof map.sourcesContent[i] !== 'undefined'
map.sourcesContent && typeof map.sourcesContent[i] !== "undefined"
? map.sourcesContent[i]
: // eslint-disable-next-line no-undefined
undefined;
const skipReading = typeof originalSourceContent !== 'undefined';
const skipReading = typeof originalSourceContent !== "undefined";
let errored = false;

// We do not skipReading here, because we need absolute paths in sources.
Expand Down Expand Up @@ -150,8 +150,8 @@ export default async function loader(input, inputMap) {
// eslint-disable-next-line no-shadow
const { sourceURL, sourceContent } = source;

newMap.sources.push(sourceURL || '');
newMap.sourcesContent.push(sourceContent || '');
newMap.sources.push(sourceURL || "");
newMap.sourcesContent.push(sourceContent || "");
});

const sourcesContentIsEmpty =
Expand All @@ -161,5 +161,5 @@ export default async function loader(input, inputMap) {
delete newMap.sourcesContent;
}

callback(null, input.replace(replacementString, ''), newMap);
callback(null, input.replace(replacementString, ""), newMap);
}
Loading

0 comments on commit 9600af0

Please sign in to comment.