Lint Your Code Into the Future
Chris Manson - @real_ate
A Process
You, a Developer
Code Reviews
A Plan
The Rules Document
Step 2
The Masked Lint
Nothing new
Real world example
<Ui::Button />
<Ui::Button class=âflexâ />
What is a lint rule anyway?
https://github.com/simplabs/ast-workshop
Lint rules in 30 seconds
Writing a lint rule
Writing a lint rule
AST Explorer

Custom Rule

Custom Rule
import { Rule } from 'ember-template-lint';
export default class NoFlex extends Rule {
visitor() {
return {
ElementNode(node) {
}
};
}
};
Custom Rule
import { Rule } from 'ember-template-lint';
export default class NoFlex extends Rule {
visitor() {
return {
ElementNode(node) {
if (node.tag === 'Ui::Button') {
}
}
};
}
};
Custom Rule
import { Rule } from 'ember-template-lint';
export default class NoFlex extends Rule {
visitor() {
return {
ElementNode(node) {
if (node.tag === 'Ui::Button') {
let classAttribute = node.attributes.find(
(attr) => attr.name === 'class'
);
}
}
};
}
};
Custom Rule
import { Rule } from 'ember-template-lint';
export default class NoFlex extends Rule {
visitor() {
return {
ElementNode(node) {
if (node.tag === 'Ui::Button') {
let classAttribute = node.attributes.find(
(attr) => attr.name === 'class'
);
if( classAttribute && classAttribute.value.chars.includes('flex')) {
}
}
}
};
}
};
Custom Rule
import { Rule } from 'ember-template-lint';
export default class NoFlex extends Rule {
visitor() {
return {
ElementNode(node) {
if (node.tag === 'Ui::Button') {
let classAttribute = node.attributes.find(
(attr) => attr.name === 'class'
);
if( classAttribute && classAttribute.value.chars.includes('flex')) {
this.log({
message: `You can't provide the 'flex' class to a Ui::Button.`,
node: node,
})
}
}
}
};
}
};
Part 2
Lint to the Future

All the errors

All the warnings

File based ignore
Install Lint to the Future
npm install lint-to-the-future lint-to-the-future-ember-template
Back to the Errors

Ignore those errors
npx lint-to-the-future ignore
The Dashboard

List those ignores
npx lint-to-the-future list --stdout
List those ignores

Output
npx lint-to-the-future output -o lttf
Output
Yesterday's News
npx lint-to-the-future output -o lttf
--previous-results https://ember-learn.github.io/ember-styleguide/data.json
take a peek if you're interested
https://ember-learn.github.io/ember-styleguide/data.json
GitHub action
name: Lint to the Future
on:
push:
branches:
- master
jobs:
deploy:
uses: mansona/lint-to-the-future-dashboard-action/.github/workflows/dashboard.yml@main
Dashboard demo
Thank you all!
- https://twitter.com/real_ate
- https://twitch.tv/real_ate
- https://github.com/mansona
-