Skip to content

Conversation

@davidhemphill
Copy link
Contributor

@davidhemphill davidhemphill commented Nov 4, 2017

In response to #93, this PR establishes the use of ESLint using Prettier for code formatting. The ESLint config is using https://github.com/postcss/eslint-config-postcss, and Prettier is configured using the following settings:

"semi": false, // Use semicolons
"singleQuote": true, // Use single quotes instead of double quotes
"printWidth": 80, // Limit each line to 80 characters
"tabWidth": 2, // Each tab is 2 spaces wide
"useTabs": false, // Use spaces instead of tabs
"trailingComma": "none", // Don't use trailing commas, even if allowed in things like arrays
"bracketSpacing": true // Use spaces between brackets

@davidhemphill davidhemphill changed the title Add ESLinting and Prettier formatting and run initial formatting Add ESLint and Prettier formatting and run initial formatting Nov 4, 2017
@davidhemphill davidhemphill changed the title Add ESLint and Prettier formatting and run initial formatting Add ESLint and Prettier formatting and run initial formatting [WIP] Nov 4, 2017
@davidhemphill davidhemphill changed the title Add ESLint and Prettier formatting and run initial formatting [WIP] Add ESLint and Prettier formatting and run initial formatting Nov 4, 2017
.eslintrc Outdated
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "none",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you choose to remove the trailing comma's?
It makes cleaner diffs, which is always nicer I think?

@adamwathan
Copy link
Member

adamwathan commented Nov 4, 2017

Sweet, excited to get this in! I agree with @MichaelDeBoey I think we should force dangling commas for multiline though, which looks like an easy tweak to the config?

EDIT: I only actually care about this if our whole config is gonna end up being custom; I'd also be fine with just following something like Standard which forbid trailing commas.

@davidhemphill
Copy link
Contributor Author

davidhemphill commented Nov 4, 2017 via email

@adamwathan
Copy link
Member

Can we also add the quote-props rule set to consistent? I hate seeing some quoted keys and some not in objects where we need to use numbers as keys or dashes in keys.

@davidhemphill
Copy link
Contributor Author

This is where we'd have to jump off the Prettier wagon. They're not interested in adding this option yet: prettier/prettier#838.

Copy link
Contributor

@MichaelDeBoey MichaelDeBoey left a comment

Choose a reason for hiding this comment

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

Maybe it's best to include a trailing comma everywhere it's possible, so we have cleaner diffs in the future?

I'm sorry for the massive amount of comments (164, wtf! 😕) btw, but wanted to make sure you didn't forget any of them 🙂

let output = defineClass('smooth', {'-webkit-font-smoothing': 'antialiased'})
expect(c(output.toString())).toEqual(`.smooth { -webkit-font-smoothing: antialiased }`)
let output = defineClass('smooth', {
'-webkit-font-smoothing': 'antialiased'
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we can add one

'flex': {
display: 'flex',
flex: {
display: 'flex'
Copy link
Contributor

Choose a reason for hiding this comment

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

This one can be re-added I guess

'inline-flex': {
display: 'inline-flex',
},
display: 'inline-flex'
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

display: 'inline-flex',
},
display: 'inline-flex'
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

src/build.js Outdated
from: `./css/${filename}.css`,
to: `./dist/${filename}.css`,
map: { inline: false },
map: { inline: false }
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

return postcss.decl({
prop: `${property}`,
value: `${value}`,
value: `${value}`
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

}).append(decls)
return postcss
.rule({
selector: `.${escapeClassName(className)}`
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

}).append(cloneNodes(rules))
return postcss
.atRule({
name: 'focusable'
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

}).append(cloneNodes(rules))
return postcss
.atRule({
name: 'hoverable'
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

}).append(cloneNodes(rules))
return postcss
.atRule({
name: 'responsive'
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

package.json Outdated
"version": "0.1.3",
"description": "A utility-first CSS framework for rapidly building custom user interfaces.",
"description":
"A utility-first CSS framework for rapidly building custom user interfaces.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's best to change the printWidth to 100 or so, so this one can be on 1 line?

throw new Error(`Specified Tailwind config file "${configFile}" doesn't exist.`)
if (!fs.existsSync(configFile)) {
throw new Error(
`Specified Tailwind config file "${configFile}" doesn't exist.`
Copy link
Contributor

Choose a reason for hiding this comment

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

This one could also be on one line again.

"tabWidth": 2,
"useTabs": false,
"trailingComma": "none",
"trailingComma": "es5",
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between this and "comma-dangle": "always-multiline"?

https://eslint.org/docs/rules/comma-dangle#options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They're the same. Always add trailing commas when using multiple lines, and not when on a single line.

// Doesn't get trailing comma
let contributors: ['adam', 'jonathan', 'steve', 'david']

// Trail those commas!
let contributors: [
  'adam',
  'jonathan',
  'steve',
  'david',
]

@adamwathan
Copy link
Member

@MichaelDeBoey No need to point out each comma; once we get the ESLint and Prettier config set the way we want it will do all of that automatically; @davidhemphill didn't make any of these changes by hand it's just the result of Prettier running with the config that was in place at the time of running it.

@MichaelDeBoey
Copy link
Contributor

@adamwathan Oh I didn't know that, I'm sorry 😕
I thought he did it all by hand so...

@adamwathan
Copy link
Member

@MichaelDeBoey Haha all good! 😊

@adamwathan adamwathan force-pushed the Add-ESLint-and-Prettier branch from 75f9c93 to bab36e0 Compare November 6, 2017 20:08
@adamwathan adamwathan merged commit 05b5bbd into master Nov 6, 2017
@adamwathan adamwathan deleted the Add-ESLint-and-Prettier branch November 6, 2017 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants