Prevent Stylelint from enforcing an alphabetical order on vendor prefixes? - lint

Is it possible to apply a flag to prevent Stylelint from enforcing an alphabetical order on vendor prefixes? I have a declaration order that I'm pleased with in my config, but my vendor prefixes are automatically generated through Autoprefixer within a gulp task on my SASS files. However I want to lint the final CSS file on the fly using Circle CI, so the CLI is perfect for that.
The issue is that by the time the file is being linted, Autoprefixer has added vendor prefixes in a non-alphabetical order, and I receive warnings and the automated tests fail. I cannot see a way to dictate the order that autoprefixer provides vendor prefixes, and these are the only warnings being thrown on my CSS at this point.
The docs clearly state Prefixed properties must always be alphabetically ordered and must always precede the unprefixed version. but is there a way around this within the config?
Thanks in advance

This is a new feature request, not really a technical question. As you've pointed out, the tool is behaving as documented. So please file an issue with stylelint articulating your idea!

Related

Best practice for NPM package with es6 modules - bundle or not

Writing an NPM package containing es6 modules, is it best practice to keep the source files separate
package.json
esm
index.js
Content1
Content1A.js
Content1A.js.map
Content1B.js
Content1B.js.map
Content2
Content2A.js
Content2A.js.map
Content2B.js
Content2B.js.map
with index.js referencing contents in subfolders, or is it better practice to bundle it into one file
package.json
esm
contents.js
contents.js.map
Seems the first method has an advantage with CommonJS modules since it gives a consumer possibility to import directly from the source and thus skip unused imports from index.js (since CommonJS modules are not tree-shakeable) but with es6 modules, this argument disappears.
Different bundlers might be capable of different things. The rest of this answer refers to Webpack which, being one of the most common bundlers, should influence decisions in this area.
The most important factor governing the decision about whether to bundle your library or not should be related to tree-shaking. No other important aspects come to mind for me.
Parameters affecting tree-shaking in Webpack
sideEffects: false
Setting in package.json that indicates whether modules in the package have side effects which needs to be executed when the module is imported but not consumed. Setting it to false indicates that no modules have side effects. May also be set to a list of modules which have side effects and other more complex values. Default seem to be true indicating that all modules have side effects.
This parameters plays a large role when using an entrypoint index in your package, from which all package exports are re-exported. Sparse imports from this index could easily cause your entire package to be bundled if this setting is not correct.
optimization.usedExports: true
Setting in webpack.config.js indicating to Webpack that all exports that are not used may be excluded. This activates a heuristic used by Terser to remove unused code inside a module. Is set to true by default.
In toy scenarios, this setting might seem efficient enough and the sideEffects flag might not seem to play a big role. This is not the case in real scenarios with more complex code where it is harder for this heuristic to do a good job.
/*#__PURE__*/
Annotation to be used before statements (such as functions) to indicate that they can be excluded if not explicitly used. These annotations also play a part in the heuristic used by Terser to remove unused code inside a module.
Conclusion
To allow your consumers to benefit the most from tree-shaking, it seems advisable to not bundle your es6 npm package and instead let the separate input modules remain separate so that the sideEffects setting in package.json may result in the consumer bundler to prune as many unused modules as possible. Rely on optimization.usedExports inside modules, evaluate bundle content and add /*#__PURE__*/ annotations where you think it could make a big difference. If everything is bundled in the same file, the sideEffects flag in package.json can't do the main part of the job as everything is in the same module and subsequently we have to rely on a lot of additional /*#__PURE__*/ annotations and heuristics in the consumer bundler to make tree-shaking as efficient as possible, which requires more from you (in terms of annotations) and does not come with any particular advantage. Remember to build your package in production mode as optimizations are not always active otherwise.
Source
https://webpack.js.org/guides/tree-shaking/
Own experiments

Any reason to version control Elm's `build-artifacts`?

Is there any reason to keep elm-stuff/build-artifacts under version control? I was thinking I'd add it to my .gitignore, since it seems to change every time my .elm file changes.
(This project ignores the whole elm-stuff folder, but that seems wrong to me because exact-dependencies.json is in there.)
The content of elm-stuff gets generated from your source code so it's generally safe to ignore it's content.
For your question about committing exact-dependencies.json or not I think you should look at what the Rust community suggests for their equivalent cargo.lock.
If you're building an application and if you care about deterministic builds then it's better to commit it. If you are writing a library it's better to leave dependency resolution to the application that is using the library.
Note that Elm enforces semantic versioning so you can have the guarantee that a package upgrade is not going to break your build. That doesn't prevent change in the behaviour, that's why if you want deterministic builds you should commit your exact-dependencies.json.

Difference between uncss and purifycss

I'm already using uncss with grunt, but stumbled upon purifycss.
I can't seem to find comparisons anywhere.
Can anyone tell me the difference between the two to help me choose the right one?
UnCSS removes unused CSS from your stylesheets.
PurifyCSS does not modify the original CSS files.
I use PurifyCSS and I full recommend.
I hope that simplify the things for you, everyone has a way to do the things. If I were you I would test both and see which one is more helpful for you.
EDIT:
PurifyCSS takes also care about JS-Files which could add CSS classes and IDs.
Here is a more recent comparison, courtesy of another similar project, purgecss: https://www.purgecss.com/comparison.html
Summary
PurifyCSS
Works with any file type, not just HTML or JS
Uses extractors, which takes the content of a file and extracts the list of CSS selectors used in it
UnCSS
Effective at removing unused selectors from web apps due to HTML emulation and JS execution.
This has a performance cost.
Most accurate tool if you don't use server-side rendering.
No extractor for JS files, but developers can create extractors for specific frameworks and file types.

Missing vim indentation files

I've always wondered why vim lacks some indentation files that would be handy for everyday life. Example: I sometimes have to deal with really messed up apache config files (/etc/apache2/sites-available/*). It's impossible to have them indented correctly by vim. With apache config files I usually try to improve indentation by typing
:set ft=xml
gg=G
:set ft=apache
I know that apache configuration files are not XML and that XML indentation doesn't work remarkably good here, but at least it's better than having every config line in the first column. There's a vim script which seems to work correctly but I have to install it on all Linux systems. If we take this plugin as an example: It's from 2007 - why did it never make it into a vim release?
The maintainer of the [indent] script has to submit the file to Bram (Vim's BDFL) for inclusion (and commit to maintaining it); that's how the process works. So, if you want to have this in the runtime, please ask the maintainer, or, (as the last update of that script on vim.org is from 2007 and he may be gone), ask on the vim_dev mailing list for someone to volunteer as such.
But... you shouldn't have to rely on those files being in the official runtime. Unless you're an atypical user without any customization, you must already have a mechanism in place to distribute your personal ~/.vimrc and plugins; if you put the script into ~/.vim/indent/, you should be all set.

Maven Plugin Execution Order and excluding js files

I have developed the pom.xml to first combine all the js files in the project and then compress the JS file. These 2 steps are two plugin and are in compile phase.
But some how few times puglin execution order is reversed and build fails. In case some one has seen this issue please redirect me to solution.
Secondly, I don't to include the JS in .war which are combined and compressed.
To strictly answer the first part of the question, plugins bound to the same phase are supposed to be executed in the same order as they are listed in the POM and any other behavior should be considered as a but (see MNG-2258). But I personally get the expected behavior with Maven 2.2.1.
Answering the second part of the question will be harder without more details:
what is the structure of your project?
where are the initial files located?
what are you using or doing (are you using the YIU Compressor of the previous question?)?
if yes, do you know that it can deal with aggregations (and thus remove the need for two executions)
where do you output compressed file?
In other words, give more info please.