Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Testing #78

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; EditorConfig file: https://EditorConfig.org
; Install the "EditorConfig" plugin into your editor to use

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use prettier defaults in this project.

Copy link
Author

@brettz9 brettz9 May 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I don't know of any functional IDE tools which leverage existing config from projects like prettier (or ESLint which has a prettier plugin) so as to do pre-linting--i.e., to set the proper indent immediately after hitting return (rather than linting on save, along with other fixes). EditorConfig, on the other hand, is well supported (and works with non-JS also).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of any functional IDE tools

Any IDE support them. Via plugins or builtin. Even VIM. Which IDE do you use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atom

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I am referring to project-aware setting of the indent.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://atom.io/packages/prettier-atom

Many projects in js community use prettier. Adding editorconfig is adding another tool for formatting by your personal preference.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, and I am aware of that Atom plugin (I have it installed). But note how it says, "format on save". It makes the changes either manually or when you save. It doesn't know instantly when you hit enter that it should immediately indent to the proper number of spaces or tabs. The EditorConfig plugin does do this.

Anyways, not a big deal, and your call of course. But EditorConfig currently fills a different purpose than Prettier, at least given the absence of tools which set the indent immediately upon hitting enter, and not waiting until save. There are plenty of projects which use both EditorConfig and ESLint, for example, even though both having settings for indent spaces. Ideally, ESLint tools would do so, but the only solution I've seen ( https://github.com/stuart-williams/eslint-tab-length ) does not work too well for me (it toggles the system default).

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
coverage
34 changes: 34 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,40 @@ test("minify", async () => {
expect(output.map).toBeFalsy();
});

test("minify with `numWorkers` option", async () => {
const bundle = await rollup({
input: "test/fixtures/unminified.js",
plugins: [terser({
numWorkers: 2
})],
});
const result = await bundle.generate({ format: "cjs" });
expect(result.output).toHaveLength(1);
const [output] = result.output;
expect(output.code).toEqual(
'"use strict";window.a=5,window.a<3&&console.log(4);\n'
);
expect(output.map).toBeFalsy();
});

test("minify with empty `nameCache.vars`", async () => {
const bundle = await rollup({
input: "test/fixtures/unminified.js",
plugins: [terser({
nameCache: {
vars: {}
}
})],
});
const result = await bundle.generate({ format: "cjs" });
expect(result.output).toHaveLength(1);
const [output] = result.output;
expect(output.code).toEqual(
'"use strict";window.a=5,window.a<3&&console.log(4);\n'
);
expect(output.map).toBeFalsy();
});

test("minify via terser options", async () => {
const bundle = await rollup({
input: "test/fixtures/empty.js",
Expand Down