Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: @putout/plugin-putout: apply-declare: add
- Loading branch information
1 parent
ec12ee7
commit d289312
Showing
27 changed files
with
119 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
'use strict'; | ||
|
||
const {operator} = require('putout'); | ||
const declarations = require('./declarations'); | ||
|
||
const {declare} = operator; | ||
|
||
module.exports = declare(declarations); | ||
module.exports.declare = () => ({ | ||
cutEnv: 'import {cutEnv} from "madrun"', | ||
}); |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
'use strict'; | ||
|
||
const {operator} = require('putout'); | ||
const declarations = require('./declarations'); | ||
|
||
const {declare} = operator; | ||
|
||
module.exports = declare(declarations); | ||
module.exports.declare = () => ({ | ||
maybeArray: 'const maybeArray = (a) => isArray(a) ? a : [a]', | ||
maybeEmptyArray: 'const maybeEmptyArray = (a) => !a ? [] : a', | ||
maybeFn: 'const maybeFn = (a) => isFn(a) ? a : noop', | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
'use strict'; | ||
|
||
const {operator} = require('putout'); | ||
const {declare} = operator; | ||
|
||
module.exports = declare({ | ||
module.exports.declare = () => ({ | ||
montag: `import montag from 'montag'`, | ||
}); | ||
|
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
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
7 changes: 7 additions & 0 deletions
7
packages/plugin-putout/lib/apply-declare/fixture/declare-fix.js
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,7 @@ | ||
const {operator} = require('putout'); | ||
const {declare} = operator; | ||
|
||
module.exports.declare = () => ({ | ||
tryCatch: `import tryCatch from 'try-catch'`, | ||
tryToCatch: `import tryToCatch from 'try-to-catch'` | ||
}); |
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,7 @@ | ||
const {operator} = require('putout'); | ||
const {declare} = operator; | ||
|
||
module.exports = declare({ | ||
tryCatch: `import tryCatch from 'try-catch'`, | ||
tryToCatch: `import tryToCatch from 'try-to-catch'`, | ||
}); |
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,8 @@ | ||
'use strict'; | ||
|
||
module.exports.report = () => `Use 'Declarator' instead of 'operator.declare'`; | ||
|
||
module.exports.replace = () => ({ | ||
'module.exports = declare(__a)': 'module.exports.declare = () => __a', | ||
}); | ||
|
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,18 @@ | ||
'use strict'; | ||
|
||
const {createTest} = require('@putout/test'); | ||
const plugin = require('.'); | ||
const test = createTest(__dirname, { | ||
'tape/apply-declare': plugin, | ||
}); | ||
|
||
test('plugin-tape: apply-declare: report', (t) => { | ||
t.report('declare', `Use 'Declarator' instead of 'operator.declare'`); | ||
t.end(); | ||
}); | ||
|
||
test('plugin-tape: apply-declare', (t) => { | ||
t.transform('declare'); | ||
t.end(); | ||
}); | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
'use strict'; | ||
|
||
const {operator} = require('putout'); | ||
const declarations = require('./declarations'); | ||
const {declare} = operator; | ||
const types = require('./types'); | ||
const operator = require('./operator'); | ||
|
||
module.exports = declare(declarations); | ||
module.exports.declare = () => ({ | ||
template: `import {template} from 'putout'`, | ||
createTest: `import {createTest} from '@putout/test'`, | ||
...operator, | ||
...types, | ||
}); | ||
|
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
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,7 @@ | ||
const {operator} = require('putout'); | ||
const {declare} = operator; | ||
|
||
module.exports.declare = () => ({ | ||
tryCatch: `import tryCatch from 'try-catch'`, | ||
tryToCatch: `import tryToCatch from 'try-to-catch'` | ||
}); |
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,7 @@ | ||
const {operator} = require('putout'); | ||
const {declare} = operator; | ||
|
||
module.exports = declare({ | ||
tryCatch: `import tryCatch from 'try-catch'`, | ||
tryToCatch: `import tryToCatch from 'try-to-catch'`, | ||
}); |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
'use strict'; | ||
|
||
const {operator} = require('putout'); | ||
const declarations = require('./declarations'); | ||
|
||
const {declare} = operator; | ||
|
||
module.exports = declare(declarations); | ||
module.exports.declare = () => ({ | ||
useState: 'import {useState} from "react"', | ||
useEffect: 'import {useEffect} from "react"', | ||
useContext: 'import {useContext} from "react"', | ||
useReducer: 'import {useReducer} from "react"', | ||
useCallback: 'import {useCallback} from "react"', | ||
}); |
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
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