fix eslint issues
This commit is contained in:
parent
ec607968cf
commit
9dbf5881cd
20 changed files with 35 additions and 47 deletions
|
|
@ -1,9 +1,12 @@
|
|||
{
|
||||
"env": {
|
||||
"jest": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"extends": ["prettier"],
|
||||
"extends": ["eslint-config-postcss", "prettier"],
|
||||
"plugins": ["prettier"],
|
||||
"rules": {
|
||||
"prettier/prettier": [
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
import postcss from 'postcss'
|
||||
import fs from 'fs'
|
||||
import _ from 'lodash'
|
||||
import c from '../src/util/collapseWhitespace'
|
||||
import defineClass from '../src/util/defineClass'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
import postcss from 'postcss'
|
||||
import fs from 'fs'
|
||||
import _ from 'lodash'
|
||||
import c from '../src/util/collapseWhitespace'
|
||||
import defineClasses from '../src/util/defineClasses'
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@
|
|||
"babelify": "babel src --out-dir lib",
|
||||
"prepare": "npm run babelify && babel-node src/build.js",
|
||||
"watch": "nodemon -e js,css --watch src --exec 'babel-node src/build.js'",
|
||||
"test": "jest and eslint ."
|
||||
"style": "eslint .",
|
||||
"test": "jest && eslint ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"autoprefixer": "^7.1.6",
|
||||
|
|
@ -33,6 +34,7 @@
|
|||
"babel-preset-stage-3": "^6.24.1",
|
||||
"clean-css": "^4.1.9",
|
||||
"eslint": "^4.10.0",
|
||||
"eslint-config-postcss": "^2.0.2",
|
||||
"eslint-config-prettier": "^2.7.0",
|
||||
"eslint-plugin-prettier": "^2.3.1",
|
||||
"jest": "^20.0.4",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ function buildDistFile(filename) {
|
|||
console.log(`Processing ./css/${filename}.css...`)
|
||||
|
||||
fs.readFile(`./css/${filename}.css`, (err, css) => {
|
||||
if (err) throw err
|
||||
|
||||
return postcss([tailwind(), require('autoprefixer')])
|
||||
.process(css, {
|
||||
from: `./css/${filename}.css`,
|
||||
|
|
|
|||
22
src/cli.js
22
src/cli.js
|
|
@ -1,12 +1,12 @@
|
|||
#!/usr/bin/env node
|
||||
/* eslint-disable no-process-exit */
|
||||
|
||||
import fs from 'fs-extra'
|
||||
import _ from 'lodash'
|
||||
import path from 'path'
|
||||
import postcss from 'postcss'
|
||||
import defaultConfig from '../defaultConfig'
|
||||
import program from 'commander'
|
||||
import fs from 'fs-extra'
|
||||
import tailwind from '..'
|
||||
import postcss from 'postcss'
|
||||
import process from 'process'
|
||||
import program from 'commander'
|
||||
|
||||
function loadConfig(configPath) {
|
||||
if (configPath === undefined) {
|
||||
|
|
@ -46,14 +46,14 @@ function buildTailwind(inputFile, config, write) {
|
|||
.catch(error => console.log(error))
|
||||
}
|
||||
|
||||
const packageJson = require(path.resolve(__dirname + '/../package.json'))
|
||||
const packageJson = require(path.resolve(__dirname, '/../package.json'))
|
||||
|
||||
program.version(packageJson.version).usage('<command> [<args>]')
|
||||
|
||||
program
|
||||
.command('init [filename]')
|
||||
.usage('[options] [filename]')
|
||||
.action(function(filename = 'tailwind.js') {
|
||||
.action((filename = 'tailwind.js') => {
|
||||
let destination = path.resolve(filename)
|
||||
|
||||
if (! path.extname(filename).includes('.js')) {
|
||||
|
|
@ -66,7 +66,7 @@ program
|
|||
}
|
||||
|
||||
const output = fs.readFileSync(
|
||||
path.resolve(__dirname + '/../defaultConfig.js'),
|
||||
path.resolve(__dirname, '/../defaultConfig.js'),
|
||||
'utf8'
|
||||
)
|
||||
fs.outputFileSync(
|
||||
|
|
@ -81,7 +81,7 @@ program
|
|||
.usage('[options] <file ...>')
|
||||
.option('-c, --config [path]', 'Path to config file')
|
||||
.option('-o, --output [path]', 'Output file')
|
||||
.action(function(file, options) {
|
||||
.action((file, options) => {
|
||||
let inputFile = program.args[0]
|
||||
|
||||
if (!inputFile) {
|
||||
|
|
@ -93,7 +93,7 @@ program
|
|||
inputFile,
|
||||
loadConfig(options.config),
|
||||
writeStrategy(options)
|
||||
).then(function() {
|
||||
).then(() => {
|
||||
process.exit()
|
||||
})
|
||||
})
|
||||
|
|
@ -102,7 +102,7 @@ program
|
|||
.command('*', null, {
|
||||
noHelp: true
|
||||
})
|
||||
.action(function() {
|
||||
.action(() => {
|
||||
program.help()
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import _ from 'lodash'
|
||||
import defineClass from '../util/defineClass'
|
||||
import defineClasses from '../util/defineClasses'
|
||||
|
||||
function defaultBorder(width, color) {
|
||||
|
|
@ -23,7 +22,7 @@ function defaultBorder(width, color) {
|
|||
}
|
||||
|
||||
function sizedBorder(size, width, color) {
|
||||
const style = width == 0 ? '0' : `${width} solid ${color}`
|
||||
const style = width == 0 ? '0' : `${width} solid ${color}` // eslint-disable-line eqeqeq
|
||||
|
||||
return defineClasses({
|
||||
[`border-${size}`]: {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable no-shadow */
|
||||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import defineClass from '../util/defineClass'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export default function({ textColors }) {
|
|||
return hoverable(
|
||||
_.map(textColors, (color, modifier) => {
|
||||
return defineClass(`text-${modifier}`, {
|
||||
color: color
|
||||
color
|
||||
})
|
||||
})
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import _ from 'lodash'
|
||||
import defineClasses from '../util/defineClasses'
|
||||
import hoverable from '../util/hoverable'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
import _ from 'lodash'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export default function(config) {
|
|||
|
||||
return functions({
|
||||
functions: {
|
||||
config: function(path, defaultValue) {
|
||||
config: (path, defaultValue) => {
|
||||
return _.get(options, _.trim(path, `'"`), defaultValue)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import postcss from 'postcss'
|
||||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import findMixin from '../util/findMixin'
|
||||
import escapeClassName from '../util/escapeClassName'
|
||||
|
||||
|
|
@ -9,10 +9,9 @@ function normalizeClassNames(classNames) {
|
|||
})
|
||||
}
|
||||
|
||||
export default function(config) {
|
||||
export default function() {
|
||||
return function(css) {
|
||||
const options = config()
|
||||
css.walkRules(function(rule) {
|
||||
css.walkRules(rule => {
|
||||
rule.walkAtRules('apply', atRule => {
|
||||
const mixins = normalizeClassNames(postcss.list.space(atRule.params))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import cloneNodes from '../util/cloneNodes'
|
||||
|
||||
export default function(config) {
|
||||
export default function() {
|
||||
return function(css) {
|
||||
const options = config()
|
||||
|
||||
css.walkAtRules('focusable', atRule => {
|
||||
atRule.walkRules(rule => {
|
||||
// Might be wise to error if the rule has multiple selectors,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import cloneNodes from '../util/cloneNodes'
|
||||
|
||||
export default function(config) {
|
||||
export default function() {
|
||||
return function(css) {
|
||||
const options = config()
|
||||
|
||||
css.walkAtRules('hoverable', atRule => {
|
||||
atRule.walkRules(rule => {
|
||||
// Might be wise to error if the rule has multiple selectors,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import fs from 'fs'
|
||||
import postcss from 'postcss'
|
||||
|
||||
export default function(config) {
|
||||
export default function() {
|
||||
return function(css) {
|
||||
const options = config()
|
||||
|
||||
css.walkAtRules('tailwind', atRule => {
|
||||
if (atRule.params === 'preflight') {
|
||||
atRule.before(
|
||||
|
|
|
|||
|
|
@ -1,12 +1,9 @@
|
|||
import _ from 'lodash'
|
||||
import postcss from 'postcss'
|
||||
import cloneNodes from '../util/cloneNodes'
|
||||
import buildMediaQuery from '../util/buildMediaQuery'
|
||||
|
||||
export default function(config) {
|
||||
return function(css) {
|
||||
const options = config()
|
||||
const rules = []
|
||||
|
||||
css.walkAtRules('screen', atRule => {
|
||||
const screen = atRule.params
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import postcss from 'postcss'
|
||||
import _ from 'lodash'
|
||||
import defineClass from './defineClass'
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export default function findMixin(css, mixin, onError) {
|
|||
const matches = []
|
||||
|
||||
css.walkRules(rule => {
|
||||
if (rule.selectors.includes(mixin) && rule.parent.type == 'root') {
|
||||
if (rule.selectors.includes(mixin) && rule.parent.type === 'root') {
|
||||
matches.push(rule)
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1536,6 +1536,10 @@ escodegen@^1.6.1:
|
|||
optionalDependencies:
|
||||
source-map "~0.5.6"
|
||||
|
||||
eslint-config-postcss@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-postcss/-/eslint-config-postcss-2.0.2.tgz#cae1c6093ced7850894a5b85fbe1d1e232b72afb"
|
||||
|
||||
eslint-config-prettier@^2.7.0:
|
||||
version "2.7.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.7.0.tgz#7bbfef66ad783277836f4ea556e68b9bcc9da4d0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue