Skip to content

Commit a656c5f

Browse files
committed
🔧 Update Prettier config
1 parent e975e20 commit a656c5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+338
-341
lines changed

.eslintrc.js

+39-45
Original file line numberDiff line numberDiff line change
@@ -5,62 +5,56 @@ module.exports = {
55
es6: true,
66
},
77
globals: {
8-
window: "readonly",
8+
window: 'readonly',
99
},
10-
parser: "@typescript-eslint/parser",
10+
parser: '@typescript-eslint/parser',
1111
parserOptions: {
12-
parser: "@babel/eslint-parser",
12+
parser: '@babel/eslint-parser',
1313
ecmaVersion: 6,
14-
sourceType: "module",
14+
sourceType: 'module',
1515
},
1616
extends: [
17-
"airbnb",
18-
"plugin:react/recommended",
19-
"plugin:react-hooks/recommended",
20-
"plugin:jsx-a11y/recommended",
21-
"plugin:@typescript-eslint/eslint-recommended",
22-
"plugin:@typescript-eslint/recommended",
23-
"prettier",
17+
'airbnb',
18+
'plugin:react/recommended',
19+
'plugin:react-hooks/recommended',
20+
'plugin:jsx-a11y/recommended',
21+
'plugin:@typescript-eslint/eslint-recommended',
22+
'plugin:@typescript-eslint/recommended',
23+
'prettier',
2424
],
2525
settings: {
26-
"import/resolver": {
26+
'import/resolver': {
2727
node: {
28-
paths: [".", "src"],
29-
extensions: [".js", ".ts"],
28+
paths: ['.', 'src'],
29+
extensions: ['.js', '.ts'],
3030
},
3131
},
3232
},
33-
plugins: [
34-
"prettier",
35-
"react",
36-
"jsx-a11y",
37-
"react-hooks",
38-
"@typescript-eslint",
39-
],
33+
plugins: ['prettier', 'react', 'jsx-a11y', 'react-hooks', '@typescript-eslint'],
4034
rules: {
41-
"import/extensions": "off",
42-
"import/prefer-default-export": "off",
43-
"import/no-webpack-loader-syntax": "off",
44-
"import/no-unresolved": "off",
45-
"import/no-extraneous-dependencies": "off",
46-
"no-use-before-define": "off",
47-
"no-console": "off",
48-
"no-extend-native": "off",
49-
"no-param-reassign": "off",
50-
"class-methods-use-this": "off",
51-
"node/no-unpublished-require": "off",
52-
"node/no-missing-import": "off",
53-
"node/no-unpublished-import": "off",
54-
"dot-notation": ["error", { allowKeywords: true }],
55-
"@typescript-eslint/explicit-module-boundary-types": "off",
56-
"@typescript-eslint/no-explicit-any": "off",
57-
"@typescript-eslint/no-var-requires": "off",
58-
"func-names": "off",
59-
"no-underscore-dangle": "off",
60-
camelcase: "warn",
61-
"no-plusplus": "off",
62-
"no-nested-ternary": "off",
63-
"@typescript-eslint/ban-types": "warn",
64-
"no-unused-expressions": "off",
35+
'import/extensions': 'off',
36+
'import/prefer-default-export': 'off',
37+
'import/no-webpack-loader-syntax': 'off',
38+
'import/no-unresolved': 'off',
39+
'import/no-extraneous-dependencies': 'off',
40+
'no-use-before-define': 'off',
41+
'no-console': 'off',
42+
'no-extend-native': 'off',
43+
'no-param-reassign': 'off',
44+
'class-methods-use-this': 'off',
45+
'node/no-unpublished-require': 'off',
46+
'node/no-missing-import': 'off',
47+
'node/no-unpublished-import': 'off',
48+
'dot-notation': ['error', { allowKeywords: true }],
49+
'@typescript-eslint/explicit-module-boundary-types': 'off',
50+
'@typescript-eslint/no-explicit-any': 'off',
51+
'@typescript-eslint/no-var-requires': 'off',
52+
'func-names': 'off',
53+
'no-underscore-dangle': 'off',
54+
camelcase: 'warn',
55+
'no-plusplus': 'off',
56+
'no-nested-ternary': 'off',
57+
'@typescript-eslint/ban-types': 'warn',
58+
'no-unused-expressions': 'off',
6559
},
6660
};

.prettierrc

-6
This file was deleted.

.prettierrc.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/** @type {import('prettier').Config} */
2+
const config = {
3+
singleQuote: true,
4+
semi: true,
5+
arrowParens: 'always',
6+
printWidth: 120,
7+
};
8+
9+
module.exports = config;

client/ExtensionCompiler.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { log } from "util";
2-
import * as webpack from "webpack";
3-
import ExtensionReloaderImpl from "../src/ExtensionReloader";
4-
import { info } from "../src/utils/logger";
5-
import { IPluginOptions } from "../typings/webpack-ext-reloader";
1+
import { log } from 'util';
2+
import * as webpack from 'webpack';
3+
import ExtensionReloaderImpl from '../src/ExtensionReloader';
4+
import { info } from '../src/utils/logger';
5+
import { IPluginOptions } from '../typings/webpack-ext-reloader';
66

77
export default class ExtensionCompiler {
88
private static treatErrors(err) {

client/args-parser.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* eslint-disable no-throw-literal */
2-
import { resolve } from "path";
3-
import { cwd } from "process";
4-
import { log } from "util";
5-
import { DEFAULT_CONFIG, DEFAULT_PORT } from "../src/constants/options.constants";
6-
import { IPluginOptions } from "../typings/webpack-ext-reloader";
7-
import { CONFIG, HELP, MANIFEST, NO_PAGE_RELOAD, PORT } from "./args.constant";
8-
import { SIG_EXIT } from "./events.constants";
9-
import manual from "./manual";
2+
import { resolve } from 'path';
3+
import { cwd } from 'process';
4+
import { log } from 'util';
5+
import { DEFAULT_CONFIG, DEFAULT_PORT } from '../src/constants/options.constants';
6+
import { IPluginOptions } from '../typings/webpack-ext-reloader';
7+
import { CONFIG, HELP, MANIFEST, NO_PAGE_RELOAD, PORT } from './args.constant';
8+
import { SIG_EXIT } from './events.constants';
9+
import manual from './manual';
1010

1111
export default (args: object) => {
1212
if (args[HELP]) {
@@ -28,7 +28,7 @@ export default (args: object) => {
2828

2929
try {
3030
// eslint-disable-next-line no-eval
31-
const webpackConfig = eval("require")(optPath);
31+
const webpackConfig = eval('require')(optPath);
3232
return { webpackConfig, pluginOptions };
3333
} catch (err) {
3434
log(`[Error] Couldn't require the file: ${optPath}`);

client/args.constant.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export const HELP = "help";
2-
export const CONFIG = "config";
3-
export const PORT = "port";
4-
export const NO_PAGE_RELOAD = "no-page-reload";
5-
export const MANIFEST = "manifest";
1+
export const HELP = 'help';
2+
export const CONFIG = 'config';
3+
export const PORT = 'port';
4+
export const NO_PAGE_RELOAD = 'no-page-reload';
5+
export const MANIFEST = 'manifest';

client/events.constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const SIG_EXIT = "SIG_EXIT";
1+
export const SIG_EXIT = 'SIG_EXIT';

client/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import * as minimist from "minimist";
2-
import { install } from "source-map-support";
3-
import { log } from "util";
4-
import argsParser from "./args-parser";
5-
import { SIG_EXIT } from "./events.constants";
6-
import ExtensionCompiler from "./ExtensionCompiler";
1+
import * as minimist from 'minimist';
2+
import { install } from 'source-map-support';
3+
import { log } from 'util';
4+
import argsParser from './args-parser';
5+
import { SIG_EXIT } from './events.constants';
6+
import ExtensionCompiler from './ExtensionCompiler';
77

88
install();
99
// eslint-disable-next-line @typescript-eslint/no-unused-vars

client/manual.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
DEFAULT_CONTENT_SCRIPT_ENTRY,
66
DEFAULT_EXTENSION_PAGE_ENTRY,
77
DEFAULT_PORT,
8-
} from "../src/constants/options.constants";
8+
} from '../src/constants/options.constants';
99

1010
export default () => `
1111
Usage:

sample/src/dependency-sample.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import assetContent from "./some-asset.txt";
1+
import assetContent from './some-asset.txt';
22

33
export default () => assetContent;

sample/src/my-background.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
console.info("Change anything here!");
1+
console.info('Change anything here!');

sample/src/my-content-script.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import depSample from "./dependency-sample";
1+
import depSample from './dependency-sample';
22

3-
console.info("Change anything here!! It will hot-reload the extension :)");
3+
console.info('Change anything here!! It will hot-reload the extension :)');
44
console.log(depSample());

sample/src/popup.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
33
<body>
44
<button id="button">Click here!</button>

sample/src/popup.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
console.info("Change anything here!");
1+
console.info('Change anything here!');
22

3-
import "./style.css";
3+
import './style.css';
44

5-
const element = document.createElement("span");
6-
element.innerText = "You clicked me! :)";
5+
const element = document.createElement('span');
6+
element.innerText = 'You clicked me! :)';
77

8-
document.getElementById("button").addEventListener("click", () => document.body.appendChild(element));
8+
document.getElementById('button').addEventListener('click', () => document.body.appendChild(element));

sample/webpack.plugin.js

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
1-
const path = require("path");
2-
const CopyWebpackPlugin = require("copy-webpack-plugin");
3-
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
4-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
5-
const ExtensionReloaderPlugin = require("../dist/webpack-ext-reloader");
1+
const path = require('path');
2+
const CopyWebpackPlugin = require('copy-webpack-plugin');
3+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
4+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5+
const ExtensionReloaderPlugin = require('../dist/webpack-ext-reloader');
66

77
const mode = process.env.NODE_ENV;
88
const targetBrowser = process.env.TARGET_BROWSER;
99

1010
module.exports = {
1111
mode,
12-
devtool: "inline-source-map",
12+
devtool: 'inline-source-map',
1313
entry: {
14-
"content-script": "./sample/src/my-content-script.js",
15-
background: "./sample/src/my-background.js",
16-
popup: "./sample/src/popup.js",
14+
'content-script': './sample/src/my-content-script.js',
15+
background: './sample/src/my-background.js',
16+
popup: './sample/src/popup.js',
1717
},
1818
output: {
19-
publicPath: ".",
20-
path: path.resolve(__dirname, "dist/", targetBrowser),
21-
filename: "[name].bundle.js",
22-
libraryTarget: "umd",
19+
publicPath: '.',
20+
path: path.resolve(__dirname, 'dist/', targetBrowser),
21+
filename: '[name].bundle.js',
22+
libraryTarget: 'umd',
2323
},
2424
plugins: [
2525
new CleanWebpackPlugin({
26-
cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), path.resolve(__dirname, "dist/", targetBrowser))],
26+
cleanOnceBeforeBuildPatterns: [path.join(process.cwd(), path.resolve(__dirname, 'dist/', targetBrowser))],
2727
cleanStaleWebpackAssets: false,
2828
verbose: true,
2929
}),
3030
new ExtensionReloaderPlugin({
3131
entries: {
32-
contentScript: "content-script",
33-
background: "background",
34-
extensionPage: "popup",
32+
contentScript: 'content-script',
33+
background: 'background',
34+
extensionPage: 'popup',
3535
},
36-
port: targetBrowser === "chrome" ? 9090 : 9091,
36+
port: targetBrowser === 'chrome' ? 9090 : 9091,
3737
reloadPage: false, // can also be true!
3838
// Also possible to use
3939
// manifest: resolve(__dirname, "manifest.json")
4040
}),
4141

42-
new MiniCssExtractPlugin({ filename: "style.css" }),
42+
new MiniCssExtractPlugin({ filename: 'style.css' }),
4343
new CopyWebpackPlugin({
4444
patterns: [
45-
{ from: "./sample/manifest.json" },
46-
{ from: "./sample/src/some-asset.txt" },
47-
{ from: "./sample/src/popup.html" },
48-
{ from: "./sample/icons" },
45+
{ from: './sample/manifest.json' },
46+
{ from: './sample/src/some-asset.txt' },
47+
{ from: './sample/src/popup.html' },
48+
{ from: './sample/icons' },
4949
],
5050
}),
5151
],
@@ -55,9 +55,9 @@ module.exports = {
5555
test: /\.js?$/,
5656
exclude: /node_modules/,
5757
use: {
58-
loader: "babel-loader",
58+
loader: 'babel-loader',
5959
options: {
60-
presets: [require("@babel/preset-env")],
60+
presets: [require('@babel/preset-env')],
6161
},
6262
},
6363
},
@@ -67,12 +67,12 @@ module.exports = {
6767
{
6868
loader: MiniCssExtractPlugin.loader,
6969
},
70-
"css-loader",
70+
'css-loader',
7171
],
7272
},
7373
{
7474
test: /\.txt$/,
75-
use: "raw-loader",
75+
use: 'raw-loader',
7676
},
7777
],
7878
},

specs/ExtensionReloader.specs.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { assert } from "chai";
2-
import { stub } from "sinon";
3-
import * as webpack from "webpack";
4-
import ExtensionReloaderImpl from "../src/ExtensionReloader";
5-
import { IExtensionReloaderInstance } from "../typings/webpack-ext-reloader";
1+
import { assert } from 'chai';
2+
import { stub } from 'sinon';
3+
import * as webpack from 'webpack';
4+
import ExtensionReloaderImpl from '../src/ExtensionReloader';
5+
import { IExtensionReloaderInstance } from '../typings/webpack-ext-reloader';
66

7-
describe("ExtensionReloader", () => {
7+
describe('ExtensionReloader', () => {
88
const envCopy = { ...process.env };
99

10-
const registerStub = stub(ExtensionReloaderImpl.prototype, "_registerPlugin").returns();
10+
const registerStub = stub(ExtensionReloaderImpl.prototype, '_registerPlugin').returns();
1111

1212
function pluginFactory(): IExtensionReloaderInstance {
1313
const plugin = new ExtensionReloaderImpl();
@@ -19,15 +19,15 @@ describe("ExtensionReloader", () => {
1919
process.env = { ...envCopy };
2020
});
2121

22-
describe("When applying plugin, should check if is in development mode", () => {
23-
it("Should check for --mode flag on versions >= 4", () => {
22+
describe('When applying plugin, should check if is in development mode', () => {
23+
it('Should check for --mode flag on versions >= 4', () => {
2424
const plugin = pluginFactory();
2525
const mockedCompiler = { options: {} } as webpack.Compiler;
2626

2727
plugin.apply(mockedCompiler);
2828
assert(registerStub.notCalled);
2929

30-
mockedCompiler.options.mode = "development";
30+
mockedCompiler.options.mode = 'development';
3131
plugin.apply(mockedCompiler);
3232
assert(registerStub.calledOnce);
3333
});

0 commit comments

Comments
 (0)