eslint-plugin-annotation
Advanced tools
Comparing version 1.1.3 to 1.1.4
{ | ||
"name": "eslint-plugin-annotation", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Lint rules to validate and auto-correct annotation-based policies", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -34,2 +34,3 @@ # eslint-plugin-annotation | ||
'annotation/sort': 'error', | ||
'annotation/unique': 'error', | ||
} | ||
@@ -36,0 +37,0 @@ } |
@@ -39,3 +39,5 @@ import { createRule } from '../utils/createRule' | ||
const elements = node.elements | ||
const uniqueElements = Array.from(new Set(elements.map((element) => sourceCode.getText(element)))) | ||
const uniqueElements = Array.from( | ||
new Set(elements.map((element) => (element === null ? '' : sourceCode.getText(element)))), | ||
) | ||
@@ -42,0 +44,0 @@ if (elements.length !== uniqueElements.length) { |
@@ -37,2 +37,16 @@ import path from 'path' | ||
}, | ||
{ | ||
code: ` | ||
// @unique | ||
const mixed = [1, "2", null, true, false]; | ||
`, | ||
filename: getFilename('main.ts'), | ||
}, | ||
{ | ||
code: ` | ||
// @unique | ||
const sparseArray = [1, 2, , 3]; | ||
`, | ||
filename: getFilename('main.ts'), | ||
}, | ||
], | ||
@@ -64,3 +78,15 @@ invalid: [ | ||
}, | ||
{ | ||
code: ` | ||
// @unique | ||
const sparseArray = [1, 2, , 1]; | ||
`, | ||
errors: [{ messageId: 'duplicateValues', type: AST_NODE_TYPES.ArrayExpression }], | ||
output: ` | ||
// @unique | ||
const sparseArray = [1, 2, ]; | ||
`, | ||
filename: getFilename('main.ts'), | ||
}, | ||
], | ||
}) |
81348
2372
56