Skip to content

Commit cb4db1a

Browse files
committed
feature: @putout/operator-sort-ignore: types
1 parent abef265 commit cb4db1a

8 files changed

Lines changed: 40 additions & 5 deletions

File tree

packages/operator-sort-ignore/.madrun.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {run} from 'madrun';
22

33
export default {
4-
'wisdom': () => run(['lint', 'coverage']),
4+
'wisdom': () => run(['lint', 'coverage', 'test:dts']),
55
'test': () => `tape 'test/*.js' 'lib/**/*.spec.js'`,
6+
'test:dts': () => 'check-dts test/*.ts',
67
'watch:test': async () => `nodemon -w lib -x "${await run('test')}"`,
78
'lint': () => 'putout .',
89
'fresh:lint': () => run('lint', '--fresh'),

packages/operator-sort-ignore/.nycrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"exclude": [
55
"**/*.spec.*",
66
"**/*.config.*",
7+
"**/*.ts",
78
"**/fixture",
89
".*.*",
910
"test"
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
2-
"printer": "putout",
2+
"rules": {
3+
"madrun/insert-test-dts": "on",
4+
"coverage/add-to-exclude": ["on", {
5+
"list": ["**/*.ts"]
6+
}]
7+
},
38
"match": {
49
"*.md": {
510
"declare": "off",
611
"putout/convert-traverse-to-scan": "off",
712
"putout/apply-remove": "off",
813
"putout/declare": "on"
914
}
10-
},
11-
"plugins": ["putout"]
15+
}
1216
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type {Traverser} from '@putout/types/plugin';
2+
3+
type SortIgnoreOptions = {
4+
name: string;
5+
type?: string;
6+
property?: string;
7+
};
8+
9+
export function sortIgnore(options: SortIgnoreOptions): Traverser;
10+

packages/operator-sort-ignore/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"url": "git+https://github.com/coderaiser/putout.git"
1515
},
1616
"scripts": {
17+
"wisdom": "madrun wisdom",
1718
"test": "madrun test",
19+
"test:dts": "madrun test:dts",
1820
"watch:test": "madrun watch:test",
1921
"lint": "madrun lint",
2022
"fresh:lint": "madrun fresh:lint",
@@ -30,6 +32,7 @@
3032
"sort-ignore"
3133
],
3234
"devDependencies": {
35+
"check-dts": "^1.0.0",
3336
"@putout/test": "^15.0.0",
3437
"eslint": "^10.0.0",
3538
"eslint-plugin-putout": "^31.0.0",
@@ -53,6 +56,7 @@
5356
"dependencies": {
5457
"@putout/babel": "^5.0.0",
5558
"@putout/operate": "^15.0.0",
56-
"@putout/operator-json": "^3.2.0"
59+
"@putout/operator-json": "^3.2.0",
60+
"@putout/types": "^1.2.0"
5761
}
5862
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {sortIgnore} from '../lib/sort-ignore.js';
2+
3+
// THROWS Argument of type 'number' is not assignable to parameter of type 'SortIgnoreOptions'
4+
sortIgnore(5);
5+
6+
sortIgnore({
7+
name: '.npmignore',
8+
// THROWS Type 'number' is not assignable to type 'string'
9+
property: 5,
10+
});

packages/putout/test/operator.errors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
findFileUp,
1515
isSimpleRegExp,
1616
addParens,
17+
sortIgnore,
1718
} = operator;
1819

1920
// THROWS Expected 2 arguments, but got 1.
@@ -60,3 +61,6 @@ isSimpleRegExp();
6061

6162
// THROWS Argument of type 'number' is not assignable to parameter of type 'NodePath_Final'
6263
addParens(5);
64+
65+
// THROWS Argument of type 'number' is not assignable to parameter of type 'SortIgnoreOptions'
66+
sortIgnore(5);

packages/putout/types/operator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export * from '@putout/operator-match-files';
1212
export * from '@putout/operator-parens';
1313
export * from '@putout/operator-regexp';
1414
export * from '@putout/operator-find-file-up';
15+
export * from '@putout/operator-sort-ignore';
1516

0 commit comments

Comments
 (0)