mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-09 12:51:50 +08:00
feat(babel6): Add task to fix function spacing
This commit is contained in:
parent
d2a4befad7
commit
5b26322c89
3 changed files with 21 additions and 1 deletions
|
@ -269,6 +269,9 @@ module.exports = (grunt) ->
|
||||||
configFile: 'build/config/eslint.json'
|
configFile: 'build/config/eslint.json'
|
||||||
target: ES_SRC
|
target: ES_SRC
|
||||||
|
|
||||||
|
eslintFixer:
|
||||||
|
src: ES_SRC
|
||||||
|
|
||||||
csslint:
|
csslint:
|
||||||
options:
|
options:
|
||||||
'adjoining-classes': false
|
'adjoining-classes': false
|
||||||
|
|
17
build/tasks/eslint-fixer-task.coffee
Normal file
17
build/tasks/eslint-fixer-task.coffee
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
fs = require('fs')
|
||||||
|
|
||||||
|
module.exports = (grunt) ->
|
||||||
|
grunt.registerMultiTask "eslintFixer", "Fixes eslint issues", ->
|
||||||
|
done = @async()
|
||||||
|
for fileset in @files
|
||||||
|
for file in fileset.src
|
||||||
|
content = fs.readFileSync(file, encoding: "utf8")
|
||||||
|
re1 = /(.*[^ ])=> (.*)/g
|
||||||
|
re2 = /(.*) =>([^ ].*)/g
|
||||||
|
eolRe = /\ +$/gm
|
||||||
|
replacer = (fullMatch, parens, rest) ->
|
||||||
|
return "#{parens} => #{rest}"
|
||||||
|
newContent = content.replace(re1, replacer)
|
||||||
|
newContent = newContent.replace(re2, replacer)
|
||||||
|
newContent = newContent.replace(eolRe, "")
|
||||||
|
fs.writeFileSync(file, newContent, encoding: 'utf8')
|
|
@ -44,7 +44,7 @@ module.exports = (grunt) ->
|
||||||
errors.push("#{f}: Spec has to start with function")
|
errors.push("#{f}: Spec has to start with function")
|
||||||
## NOTE: Comment me in if you want to fix these files.
|
## NOTE: Comment me in if you want to fix these files.
|
||||||
# _str = require('underscore.string')
|
# _str = require('underscore.string')
|
||||||
# replacer = (match, describeName, offset, string) ->
|
# replacer = (match, describeName) ->
|
||||||
# fnName = _str.camelize(describeName, true)
|
# fnName = _str.camelize(describeName, true)
|
||||||
# return "\ndescribe('#{describeName}', function #{fnName}() "
|
# return "\ndescribe('#{describeName}', function #{fnName}() "
|
||||||
# newContent = content.replace(describeRe, replacer)
|
# newContent = content.replace(describeRe, replacer)
|
||||||
|
|
Loading…
Add table
Reference in a new issue