-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
8a8dd67
commit 86c5230
Showing
25 changed files
with
282 additions
and
14 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
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 |
---|---|---|
|
@@ -6,4 +6,5 @@ dist | |
fixture | ||
coverage | ||
examples | ||
rules | ||
|
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
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,11 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"plugin:n/recommended", | ||
"plugin:putout/esm" | ||
], | ||
"plugins": [ | ||
"n", | ||
"putout" | ||
] | ||
} |
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,6 @@ | ||
node_modules | ||
*.swp | ||
yarn-error.log | ||
|
||
coverage | ||
.idea |
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,13 @@ | ||
import {run} from 'madrun'; | ||
|
||
export default { | ||
'prepublishOnly': () => run(['lint', 'test']), | ||
'test': () => `tape 'test/*.js' 'lib/**/*.spec.js'`, | ||
'watch:test': async () => `nodemon -w lib -x ${await run('test')}`, | ||
'lint': () => 'putout .', | ||
'fresh:lint': async () => await run('lint', '--fresh'), | ||
'lint:fresh': async () => await run('lint', '--fresh'), | ||
'fix:lint': async () => await run('lint', '--fix'), | ||
'coverage': async () => `c8 ${await run('test')}`, | ||
'report': () => 'c8 report --reporter=lcov', | ||
}; |
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,6 @@ | ||
.* | ||
*.spec.js | ||
test | ||
fixture | ||
yarn-error.log | ||
coverage |
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,14 @@ | ||
{ | ||
"check-coverage": true, | ||
"all": true, | ||
"exclude": [ | ||
"**/*.spec.*", | ||
"**/fixture", | ||
"test", | ||
".*.*" | ||
], | ||
"branches": 100, | ||
"lines": 100, | ||
"functions": 100, | ||
"statements": 100 | ||
} |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) coderaiser | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,53 @@ | ||
# @putout/plugin-goldstein [![NPM version][NPMIMGURL]][NPMURL] | ||
|
||
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-goldstein.svg?style=flat&longCache=true | ||
[NPMURL]: https://npmjs.org/package/@putout/plugin-goldstein "npm" | ||
|
||
> JavaScript with no limits 🤫. | ||
> | ||
> (c) [**Goldstein**](https://github.com/coderaiser/goldstein) | ||
🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to fix issues with | ||
**Madrun** config file. | ||
|
||
## Install | ||
|
||
``` | ||
npm i putout @putout/plugin-goldstein -D | ||
``` | ||
|
||
## Rules | ||
|
||
```json | ||
{ | ||
"rules": { | ||
"goldstein/convert-t-compile-to-compile": "on" | ||
} | ||
} | ||
``` | ||
|
||
## convert-t-compile-to-compile | ||
|
||
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/a10dd187dc3c6be8df110a8481b9d9bc/3abfc0879aad5ccff5c8e4851cb3ad06270c986e). | ||
|
||
### ❌ Example of incorrect code | ||
|
||
```js | ||
test('goldstein: keyword: import', async ({compile}) => { | ||
await compile('import'); | ||
t.end(); | ||
}); | ||
``` | ||
|
||
### ✅ Example of correct code | ||
|
||
```js | ||
test('goldstein: keyword: import', async ({compile}) => { | ||
await compile('import'); | ||
t.end(); | ||
}); | ||
``` | ||
|
||
## License | ||
|
||
MIT |
3 changes: 3 additions & 0 deletions
3
rules/goldstein/lib/convert-t-compile-to-compile/fixture/convert-t-compile-to-compile-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,3 @@ | ||
test('goldstein: keyword: import', async ({compile}) => { | ||
await compile('import'); | ||
}); |
5 changes: 5 additions & 0 deletions
5
rules/goldstein/lib/convert-t-compile-to-compile/fixture/convert-t-compile-to-compile.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,5 @@ | ||
test('goldstein: keyword: import', (t) => { | ||
t.compile('import'); | ||
t.end(); | ||
}); | ||
|
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,30 @@ | ||
import {types} from 'putout'; | ||
|
||
const { | ||
ObjectProperty, | ||
ObjectPattern, | ||
Identifier, | ||
} = types; | ||
|
||
const COMPUTED = false; | ||
const SHORTHAND = true; | ||
|
||
export const report = () => `Use 'compile()' instead of 't.compile'`; | ||
|
||
export const replace = () => ({ | ||
't.end()': '', | ||
't.compile(__a)': (vars, path) => { | ||
const {block} = path.scope; | ||
|
||
path.scope.block.async = true; | ||
|
||
const id = Identifier('compile'); | ||
const param = ObjectPattern([ | ||
ObjectProperty(id, id, COMPUTED, SHORTHAND), | ||
]); | ||
|
||
block.params = [param]; | ||
|
||
return 'await compile(__a)'; | ||
}, | ||
}); |
19 changes: 19 additions & 0 deletions
19
rules/goldstein/lib/convert-t-compile-to-compile/index.spec.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,19 @@ | ||
import {createTest} from '@putout/test'; | ||
import * as plugin from './index.js'; | ||
|
||
const test = createTest(import.meta.url, { | ||
printer: 'putout', | ||
plugins: [ | ||
['convert-t-compile-to-compile', plugin], | ||
], | ||
}); | ||
|
||
test('rules: convert-t-compile-to-compile: report', (t) => { | ||
t.report('convert-t-compile-to-compile', `Use 'compile()' instead of 't.compile'`); | ||
t.end(); | ||
}); | ||
|
||
test('rules: convert-t-compile-to-compile: transform', (t) => { | ||
t.transform('convert-t-compile-to-compile'); | ||
t.end(); | ||
}); |
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,5 @@ | ||
import * as convertTCompileToCompile from './convert-t-compile-to-compile/index.js'; | ||
|
||
export const rules = { | ||
'convert-t-compile-to-compile': convertTCompileToCompile, | ||
}; |
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,52 @@ | ||
{ | ||
"name": "@putout/plugin-goldstein", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"author": "coderaiser <[email protected]> (https://github.com/coderaiser)", | ||
"description": "🐊Putout plugin adds ability to transform madrun scripts", | ||
"homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-madrun#readme", | ||
"main": "lib/index.js", | ||
"release": false, | ||
"tag": false, | ||
"changelog": false, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/coderaiser/putout.git" | ||
}, | ||
"scripts": { | ||
"test": "madrun test", | ||
"watch:test": "madrun watch:test", | ||
"lint": "madrun lint", | ||
"fresh:lint": "madrun fresh:lint", | ||
"lint:fresh": "madrun lint:fresh", | ||
"fix:lint": "madrun fix:lint", | ||
"coverage": "madrun coverage", | ||
"report": "madrun report" | ||
}, | ||
"dependencies": {}, | ||
"keywords": [ | ||
"putout", | ||
"putout-plugin", | ||
"plugin", | ||
"madrun" | ||
], | ||
"devDependencies": { | ||
"@putout/test": "^7.0.0", | ||
"c8": "^8.0.0", | ||
"eslint": "^8.0.1", | ||
"eslint-plugin-n": "^16.0.0", | ||
"eslint-plugin-putout": "^19.0.0", | ||
"madrun": "^9.0.0", | ||
"nodemon": "^3.0.1" | ||
}, | ||
"peerDependencies": { | ||
"putout": ">=31" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
rules/goldstein/test/fixture/convert-t-compile-to-compile-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,4 @@ | ||
test('goldstein: keyword: import', async ({compile}) => { | ||
await compile('import'); | ||
t.end(); | ||
}); |
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,5 @@ | ||
test('goldstein: keyword: import', (t) => { | ||
t.compile('import'); | ||
t.end(); | ||
}); | ||
|
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,14 @@ | ||
import {createTest} from '@putout/test'; | ||
import * as goldstein from '../lib/index.js'; | ||
|
||
const test = createTest(import.meta.url, { | ||
printer: 'putout', | ||
plugins: [ | ||
['goldstein', goldstein], | ||
], | ||
}); | ||
|
||
test('plugin-goldstein: transform: convert-t-compile-to-compile', (t) => { | ||
t.transform('convert-t-compile-to-compile'); | ||
t.end(); | ||
}); |