@voiceflow/eslint-plugin 1.1.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/build/index.d.ts +10 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +20 -0
- package/build/index.js.map +1 -0
- package/build/rules/entity-property-order.d.ts +3 -0
- package/build/rules/entity-property-order.d.ts.map +1 -0
- package/build/rules/entity-property-order.js +76 -0
- package/build/rules/entity-property-order.js.map +1 -0
- package/build/rules/index.d.ts +4 -0
- package/build/rules/index.d.ts.map +1 -0
- package/build/rules/index.js +8 -0
- package/build/rules/index.js.map +1 -0
- package/package.json +37 -0
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ESLintUtils } from '@typescript-eslint/utils/';
|
|
2
|
+
import type { ESLint } from 'eslint';
|
|
3
|
+
import { rules } from './rules';
|
|
4
|
+
type RuleKey = keyof typeof rules;
|
|
5
|
+
interface Plugin extends Omit<ESLint.Plugin, 'rules'> {
|
|
6
|
+
rules: Record<RuleKey, ESLintUtils.RuleModule<any, any, any, any>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const voiceflowConfig: Plugin;
|
|
9
|
+
export default voiceflowConfig;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,KAAK,OAAO,GAAG,MAAM,OAAO,KAAK,CAAC;AAElC,UAAU,MAAO,SAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACnD,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,eAAe,EAAE,MAa7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.voiceflowConfig = void 0;
|
|
4
|
+
const rules_1 = require("./rules");
|
|
5
|
+
exports.voiceflowConfig = {
|
|
6
|
+
meta: {
|
|
7
|
+
name: '@voiceflow/eslint-plugin',
|
|
8
|
+
version: '0.0.1',
|
|
9
|
+
},
|
|
10
|
+
rules: rules_1.rules,
|
|
11
|
+
configs: {
|
|
12
|
+
creatorApp: {
|
|
13
|
+
rules: {
|
|
14
|
+
'@voiceflow/eslint-plugin/entity-property-order': 'error',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
exports.default = exports.voiceflowConfig;
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAGA,mCAAgC;AAQnB,QAAA,eAAe,GAAW;IACrC,IAAI,EAAE;QACJ,IAAI,EAAE,0BAA0B;QAChC,OAAO,EAAE,OAAO;KACjB;IACD,KAAK,EAAL,aAAK;IACL,OAAO,EAAE;QACP,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,gDAAgD,EAAE,OAAO;aAC1D;SACF;KACF;CACF,CAAC;AAEF,kBAAe,uBAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-property-order.d.ts","sourceRoot":"","sources":["../../src/rules/entity-property-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,0BAA0B,CAAC;AAOnE,eAAO,MAAM,uBAAuB,uEAsElC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entityPropertyOrderRule = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const createRule = utils_1.ESLintUtils.RuleCreator((name) => `@voiceflow/${name}`);
|
|
6
|
+
exports.entityPropertyOrderRule = createRule({
|
|
7
|
+
name: 'entity-property-order',
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'problem',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Enforce that environmentID is declared before id in MikroORM entity classes',
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
wrongOrder: 'environmentID must be declared before id in entity classes',
|
|
15
|
+
},
|
|
16
|
+
fixable: 'code',
|
|
17
|
+
schema: [],
|
|
18
|
+
},
|
|
19
|
+
defaultOptions: [],
|
|
20
|
+
create: (context) => ({
|
|
21
|
+
ClassDeclaration(node) {
|
|
22
|
+
// Check if this is an entity class (has @Entity decorator)
|
|
23
|
+
const hasEntityDecorator = node.decorators?.some((decorator) => {
|
|
24
|
+
if (decorator.expression.type === 'CallExpression') {
|
|
25
|
+
return decorator.expression.callee.type === 'Identifier' && decorator.expression.callee.name === 'Entity';
|
|
26
|
+
}
|
|
27
|
+
return decorator.expression.type === 'Identifier' && decorator.expression.name === 'Entity';
|
|
28
|
+
});
|
|
29
|
+
if (!hasEntityDecorator) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const environmentIDProperty = node.body.body.find((member) => member.type === 'PropertyDefinition' &&
|
|
33
|
+
member.key.type === 'Identifier' &&
|
|
34
|
+
member.key.name === 'environmentID') ?? null;
|
|
35
|
+
const idProperty = node.body.body.find((member) => member.type === 'PropertyDefinition' &&
|
|
36
|
+
member.key.type === 'Identifier' &&
|
|
37
|
+
member.key.name.toLowerCase() === 'id') ?? null;
|
|
38
|
+
// If both properties exist, check their order
|
|
39
|
+
if (!environmentIDProperty || !idProperty) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const environmentIDIndex = node.body.body.indexOf(environmentIDProperty);
|
|
43
|
+
const idIndex = node.body.body.indexOf(idProperty);
|
|
44
|
+
if (environmentIDIndex > idIndex) {
|
|
45
|
+
context.report({
|
|
46
|
+
node: idProperty,
|
|
47
|
+
messageId: 'wrongOrder',
|
|
48
|
+
fix(fixer) {
|
|
49
|
+
const { sourceCode } = context;
|
|
50
|
+
// Get the text of both properties including decorators
|
|
51
|
+
const environmentIDText = getPropertyWithDecorators(environmentIDProperty, sourceCode);
|
|
52
|
+
const idText = getPropertyWithDecorators(idProperty, sourceCode);
|
|
53
|
+
// Remove both properties and insert them in correct order
|
|
54
|
+
return [fixer.replaceText(environmentIDProperty, idText), fixer.replaceText(idProperty, environmentIDText)];
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
function getPropertyWithDecorators(property, sourceCode) {
|
|
62
|
+
// Get decorators that belong to this property
|
|
63
|
+
const decorators = property.decorators || [];
|
|
64
|
+
if (decorators.length === 0) {
|
|
65
|
+
return sourceCode.getText(property);
|
|
66
|
+
}
|
|
67
|
+
// Find the range from first decorator to the property
|
|
68
|
+
const firstDecorator = decorators[0];
|
|
69
|
+
if (!firstDecorator) {
|
|
70
|
+
return sourceCode.getText(property);
|
|
71
|
+
}
|
|
72
|
+
const start = firstDecorator.range[0];
|
|
73
|
+
const end = property.range[1];
|
|
74
|
+
return sourceCode.text.slice(start, end);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=entity-property-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-property-order.js","sourceRoot":"","sources":["../../src/rules/entity-property-order.ts"],"names":[],"mappings":";;;AACA,oDAAuD;AAIvD,MAAM,UAAU,GAAG,m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AAU,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC;IAE7C,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,sDAAsD;IACtD,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACrC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE9B,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,KAAK;;CAEjB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rules = void 0;
|
|
4
|
+
const entity_property_order_1 = require("./entity-property-order");
|
|
5
|
+
exports.rules = {
|
|
6
|
+
'entity-property-order': entity_property_order_1.entityPropertyOrderRule,
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":";;;AAAA,mEAAkE;AAErD,QAAA,KAAK,GAAG;IACnB,uBAAuB,EAAE,+CAAuB;CACjD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voiceflow/eslint-plugin",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"main": "build/index.js",
|
|
5
|
+
"types": "build/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"build"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "yarn g:build:pkg",
|
|
11
|
+
"clean": "yarn g:rimraf build",
|
|
12
|
+
"lint": "yarn g:run-p -c lint:eslint lint:prettier",
|
|
13
|
+
"lint:eslint": "yarn g:eslint .",
|
|
14
|
+
"lint:fix": "yarn g:run-p -c \"lint:eslint --fix\" \"lint:prettier --write\"",
|
|
15
|
+
"lint:prettier": "yarn g:prettier --check .",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:dependencies": "yarn g:depcruise",
|
|
18
|
+
"test:watch": "vitest run --watch"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/eslint": "9.6.1",
|
|
22
|
+
"@typescript-eslint/rule-tester": "8.21.0",
|
|
23
|
+
"@typescript-eslint/utils": "8.21.0",
|
|
24
|
+
"vitest": "3.0.3"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@typescript-eslint/parser": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
28
|
+
"eslint": "^8.0.0 || ^9.0.0"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": "20"
|
|
32
|
+
},
|
|
33
|
+
"volta": {
|
|
34
|
+
"extends": "../../package.json"
|
|
35
|
+
},
|
|
36
|
+
"gitHead": "f051faf3a735ff6f949da35b2d1ea8284af53180"
|
|
37
|
+
}
|