Linting
Christopher Hough
??Founder & Principal Engineer ??1st Principles Thinker ?? Ruby ?? APIs ?? Mentoring ?? Adapt ?Adjust ? Overcome ????♂? ????♂? ????♂? ?? What can we build together?
During our lunch and learn last week I had the privilege of giving a presentation on “Linting.” Why it’s both an educational tool, and a key component in quality focused engineering.” In a nutshell “a linter is a small program that checks code for stylistic or programming errors.” In my opinion it helps with training and skill gaps, is a great evaluation tool during the hiring process, and their use in organizations help attract and retain top talent. They’re also a key code quality metric, and help drive consistency across small and large teams. If you’re building an SOA and not using them, you’re doing it wrong. Why? I will give you one for free... If your coding patterns are consistent it’s easier for people to hop in and out of distributed projects reducing silos. Think efficiency. They also help curb the dreaded home grown DSL that some engineers try to implement for only God knows why. It doesn’t matter if you’re a team of one or Facebook, linters matter. In this presentation I covered rubocop for ruby, eslint for javascript, and stylelint for sass. A rails project can have even more, but those are the core three in my opinion. If you’re not familiar with this technology, I’m happy to help you. If you’re aware of them and refuse to use them, I can’t help you. You’re a lost cause. Sorry not sorry. If you’re just getting started on a project and your goal is “many, many thousands of green people from history times” don’t make the mistake of starting without them. Trust me, adding them later is beyond painful. #qualityfocusedengineering #xp #agiledevelopment #ruby #javascript #sass #collaborate
Principal Software Developer
6 年The timing of this post is uncanny. I checked ESLint into a small React project just yesterday. While I’ve used linters for years, I started off this one without installing ESLint upfront. I didn’t think it’d be a big deal to add it later since I knew most of the basic rules. Boy, was I wrong. Even though it was a small app of around 20 JS files, getting all the code to pass took me the better part of a day. Most of it was whitespace-related or the result of missing best practices like having PropTypes for type validation. ESLint also caught some bad programming choices I doubt even a human would notice. I did have to change the config to support JSX and ES6 syntax. Aside from that, the setup was pretty trivial. I extend the standard lint rules and don’t change any of the defaults (e.g. keeping tabs at 2 spaces). Visual Studio Code now tells me in real-time if I’m straying from the path. I’ve had other projects where the task runner doesn’t allow a build unless all warnings and errors are patched. That can be more helpful in team environments where everyone has their own style.
Lead Engineer and Technical Product Owner | Design Systems at Nike
6 年Yes yes yes! I’m a huge proponent of a node package called ‘husky’ that adds hooks to npm scripts to the git life cycle. Upon ‘git push’ all linting and tests have to pass. Sounds strict, but a lot of tools like eslint have an autofix flag that takes care of 90% of the work.