ESLint all the things, IDE Integration, Prettier
Highlights
- Complete IDE Integration with the new
crafty ide
command ( #40 ) - Replace TSLint with ESLint ( #290 )
- Add Prettier for CSS, JavaScript and TypeScript formatting ( #17 )
- Performance improvements for startup and compilation
- Stylelint improvements
crafty ide
for IDE Integration
Since the first day of Crafty, the goal has been to reduce the number of configuration
files that have to be managed by hand.
This is a big advantage for managing many projects, but is an inconveninent as IDEs can't
find the expected configuration files to configure themselves.
With the new crafty ide
command, you get the best of both worlds, Crafty is still configured through a single
file and your IDE will get what it needs as this command will output the configuration files for it.
Integrations are now done for:
- ESLint with
.eslintrc.js
- Stylelint with
stylelint.config.js
- Jest with
jest.config.js
- Prettier with
prettier.config.js
On top of that, as these files are specific to your configuration and for some of them, specific to the user's environment.
A .gitignore
file is automatically created, or your existing gitignore is modified.
Replace TSLint with ESLint
TSLint, while being adapted specifically for TypeScript is harder to configure, has less rules and a smaller community than ESLint.
That's some of the reasons why the TypeScript team announced they will participate in the effort of making ESLint work great with TypeScript.
The TSLint team also announced they will deprecate TSLint and help with adding the rules that didn't exist yet in ESLint.
What this means for you in practice:
- The command
crafty tsLint
has been removed and nowcrafty jsLint
works for TypeScript as well - All dependencies for ESLint have been moved from
@swissquote/crafty-preset-babel
into@swissquote/crafty-preset-eslint
crafty jsLint
is now provided by@swissquote/crafty-preset-eslint
- Our eslint plugin
@swissquote/eslint-plugin-swissquote
now supports TypeScript out of the box
One thing that might surprise you is that our ESLint configuration has way more rules enabled, so one the first update, you will probably see a lot more things reported compared to what you were used to.
Prettier
Prettier is quickly becoming the de-facto standard for code formatting in many languages.
Its approach is to format your code always the same way, with a minimum of configuration options, reducing code-formatting bike-shedding to almost non-existent.
Luckily, our code style rules, were pretty much aligned with what Prettier applies by default making the transition as painless as possible.
With this change all our CSS, JavaScript and TypeScript is formatted with Prettier.
We also disabled all our ESLint and Stylelint rules specific to formatting.
Performance improvements
- Added
fork-ts-webpack-checker-plugin
to check TypeScript on a separate thread. Enabled only if you don't need declarations. - Replace
chalk
withansi-colors
- Replace
meow
with a direct use ofyargs-parser
- Lazy load
jest-cli
andcaniuse-cli
for faster initial start
Stylelint Changes
- Use Prettier to format CSS
- Added Stylelint rule to detect use of
-var
and recommend to usecalc(var() * -1)
instead - Added
no-unsupported-browser-features
plugin to Stylelint #287
Other changes
- Allow a preset to depend from another preset.
- Bugfix
extractCSS
configuration interpretation. #289 Thanks to @vitalishapovalov for the fix. - Add
react-hot-loader
to webpack's resolve aliases to avoid having to install it separately in a project. - Error management improvements
- Warns on webpack configuration in case of missing
tsconfig.json
- Improve logging in case of incorrect stylelint configuration
- Improve logging in case of error in a Crafty command's code.
- Warns on webpack configuration in case of missing
Updates
autoprefixer
from 9.5.0 to 9.5.1@babel/*
from 7.4.0 to 7.4.4babel-loader
from 8.0.5 to 8.0.6babel-plugin-istanbul
from 5.1.1 to 5.1.4browserslist
from 4.5.3 to 4.6.0confusing-browser-globals
from 1.0.6 to 1.0.7enzyme-adapter-react-16
from 1.11.2 to 1.13.0eslint-plugin-import
from 2.16.0 to 2.17.2eslint-plugin-react
from 7.12.4 to 7.13.0gulp-svgmin
from 2.1.0 to 2.2.0gulp-terser
from 1.1.7 to 1.2.0inspectpack
from 4.1.2 to 4.2.1jest-cli
from 24.6.0 to 24.8.0jest
from 24.6.0 to 24.8.0postcss
from 7.0.14 to 7.0.16react-hot-loader
from 4.8.2 to 4.8.7resolve-from
from 4.0.0 to 5.0.0rollup
from 1.8.0 to 1.12.3rollup-plugin-commonjs
from 9.2.3 to 10.0.0rollup-plugin-node-resolve
from 4.0.1 to 5.0.0rollup-plugin-replace
from 2.1.1 to 2.2.0stylelint
from 9.10.1 to 10.0.1stylelint-scss
from 3.5.4 to 3.6.1terser-webpack-plugin
from 1.2.3 to 1.2.4ts-jest
from 24.0.1 to 24.0.2ts-loader
from 5.3.3 to 6.0.1typescript
from 3.4.1 to 3.4.5undertaker
from 1.2.0 to 1.2.1webpack-chain
from 5.2.4 to 6.0.0webpack-dev-server
from 3.2.1 to 3.4.1webpack
from 4.29.6 to 4.32.0