-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b927f31
commit 3368afb
Showing
5 changed files
with
493 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
website/src/parsers/js/transformers/putout/codeExample.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { | ||
types, | ||
} = require('putout'); | ||
|
||
module.exports.report = ({path}) => `identifier ${path.node.name} should be reversed`; | ||
|
||
module.exports.fix = ({path}) => { | ||
path.node.name = path.node.name.split('').reverse().join(''); | ||
}; | ||
|
||
module.exports.traverse = ({push}) => { | ||
return { | ||
Identifier(path) { | ||
push({path}) | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import compileModule from '../../../utils/compileModule'; | ||
import pkg from 'putout/package.json'; | ||
|
||
const ID = 'putout'; | ||
const name = 'putout'; | ||
|
||
export default { | ||
id: ID, | ||
displayName: name, | ||
version: pkg.version, | ||
homepage: pkg.homepage, | ||
|
||
defaultParserID: 'babylon7', | ||
|
||
loadTransformer(callback) { | ||
require( | ||
['putout/dist/putout.js'], | ||
(putout) => callback({ putout }) | ||
); | ||
}, | ||
|
||
transform({ putout }, transformCode, source) { | ||
const plugin = compileModule(transformCode, { | ||
require: () => putout, | ||
}); | ||
|
||
const { code } = putout(source, { | ||
plugins: [{ | ||
plugin, | ||
}], | ||
}); | ||
|
||
return code; | ||
}, | ||
}; |
Oops, something went wrong.