@kensio/smartass 1.24.0 → 1.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -161,3 +161,28 @@ structure.
161
161
  - [typeTypedArray](src/assert/type-typed-array/type-typed-array.match.ts)
162
162
  - [uuidV4](src/assert/uuid/uuid-v4.match.ts)
163
163
  <!-- matcher-functions:end -->
164
+
165
+ ## Optional ESLint config
166
+
167
+ The `@kensio/smartass` package also exports an optional ESLint flat config that discourages less
168
+ specific assertion usage. For example:
169
+
170
+ ```typescript
171
+ assertIdentical(foo.length, 2);
172
+ // suggested improvement:
173
+ assertArrayLength(foo, 2);
174
+ ```
175
+
176
+ You can use this in your ESLint config like this:
177
+
178
+ ```typescript
179
+ import { defineConfig } from "eslint/config";
180
+ import tseslint from "typescript-eslint";
181
+
182
+ import { smartassAssertions } from "@kensio/smartass/eslint";
183
+
184
+ export default defineConfig(
185
+ ...tseslint.configs.recommended,
186
+ ...smartassAssertions,
187
+ );
188
+ ```
@@ -0,0 +1,2 @@
1
+ export declare const smartassAssertions: import("eslint/config").Config[];
2
+ //# sourceMappingURL=smartass-eslint.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartass-eslint.config.d.ts","sourceRoot":"","sources":["../../src/eslint/smartass-eslint.config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,kCA+B7B,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { defineConfig } from "eslint/config";
2
+ export const smartassAssertions = defineConfig({
3
+ name: "@kensio/smartass/assertions",
4
+ rules: {
5
+ "no-restricted-syntax": [
6
+ "warn",
7
+ {
8
+ selector: "CallExpression[callee.name='assertIdentical'] > Literal[value=true]:nth-child(2)",
9
+ message: "Use assertTrue(value) instead of assertIdentical(value, true).",
10
+ },
11
+ {
12
+ selector: "CallExpression[callee.name='assertIdentical'] > Literal[value=false]:nth-child(2)",
13
+ message: "Use assertFalse(value) instead of assertIdentical(value, false).",
14
+ },
15
+ {
16
+ selector: "CallExpression[callee.name='assertIdentical'] > MemberExpression[property.name='length']:first-child",
17
+ message: "Use a more specific length assertion, such as assertArrayLength(value, expectedLength) or assertStringLength(value, expectedLength), instead of assertIdentical(value.length, expectedLength).",
18
+ },
19
+ {
20
+ selector: "CallExpression[callee.name='assertIdentical'] > MemberExpression[property.name='size']:first-child",
21
+ message: "Use a more specific size assertion, such as assertSetSize(value, expectedSize) or assertMapSize(value, expectedSize), instead of assertIdentical(value.size, expectedSize).",
22
+ },
23
+ ],
24
+ },
25
+ });
26
+ //# sourceMappingURL=smartass-eslint.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartass-eslint.config.js","sourceRoot":"","sources":["../../src/eslint/smartass-eslint.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC;IAC7C,IAAI,EAAE,6BAA6B;IACnC,KAAK,EAAE;QACL,sBAAsB,EAAE;YACtB,MAAM;YACN;gBACE,QAAQ,EACN,kFAAkF;gBACpF,OAAO,EACL,gEAAgE;aACnE;YACD;gBACE,QAAQ,EACN,mFAAmF;gBACrF,OAAO,EACL,kEAAkE;aACrE;YACD;gBACE,QAAQ,EACN,sGAAsG;gBACxG,OAAO,EACL,gMAAgM;aACnM;YACD;gBACE,QAAQ,EACN,oGAAoG;gBACtG,OAAO,EACL,6KAA6K;aAChL;SACF;KACF;CACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "url": "https://github.com/KensioSoftware/smartass"
8
8
  },
9
9
  "license": "Apache-2.0",
10
- "version": "1.24.0",
10
+ "version": "1.25.0",
11
11
  "type": "module",
12
12
  "main": "./dist/index.js",
13
13
  "types": "./dist/index.d.ts",
@@ -15,6 +15,10 @@
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
17
  "import": "./dist/index.js"
18
+ },
19
+ "./eslint": {
20
+ "types": "./dist/eslint/smartass-eslint.config.d.ts",
21
+ "import": "./dist/eslint/smartass-eslint.config.js"
18
22
  }
19
23
  },
20
24
  "files": [