UNPKG

3.45 kBJavaScriptView Raw
1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3 if (k2 === undefined) k2 = k;
4 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5}) : (function(o, m, k, k2) {
6 if (k2 === undefined) k2 = k;
7 o[k2] = m[k];
8}));
9var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10 Object.defineProperty(o, "default", { enumerable: true, value: v });
11}) : function(o, v) {
12 o["default"] = v;
13});
14var __importStar = (this && this.__importStar) || function (mod) {
15 if (mod && mod.__esModule) return mod;
16 var result = {};
17 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18 __setModuleDefault(result, mod);
19 return result;
20};
21var _a;
22Object.defineProperty(exports, "__esModule", { value: true });
23const utils_1 = require("@typescript-eslint/utils");
24const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
25const util = __importStar(require("../util"));
26const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('semi');
27exports.default = util.createRule({
28 name: 'semi',
29 meta: {
30 type: 'layout',
31 docs: {
32 description: 'Require or disallow semicolons instead of ASI',
33 // too opinionated to be recommended
34 recommended: false,
35 extendsBaseRule: true,
36 },
37 fixable: 'code',
38 hasSuggestions: baseRule.meta.hasSuggestions,
39 schema: baseRule.meta.schema,
40 // TODO: this rule has only had messages since v7.0 - remove this when we remove support for v6
41 messages: (_a = baseRule.meta.messages) !== null && _a !== void 0 ? _a : {
42 missingSemi: 'Missing semicolon.',
43 extraSemi: 'Extra semicolon.',
44 },
45 },
46 defaultOptions: [
47 'always',
48 {
49 omitLastInOneLineBlock: false,
50 beforeStatementContinuationChars: 'any',
51 },
52 ],
53 create(context) {
54 const rules = baseRule.create(context);
55 const checkForSemicolon = rules.ExpressionStatement;
56 /*
57 The following nodes are handled by the member-delimiter-style rule
58 AST_NODE_TYPES.TSCallSignatureDeclaration,
59 AST_NODE_TYPES.TSConstructSignatureDeclaration,
60 AST_NODE_TYPES.TSIndexSignature,
61 AST_NODE_TYPES.TSMethodSignature,
62 AST_NODE_TYPES.TSPropertySignature,
63 */
64 const nodesToCheck = [
65 utils_1.AST_NODE_TYPES.PropertyDefinition,
66 utils_1.AST_NODE_TYPES.TSAbstractPropertyDefinition,
67 utils_1.AST_NODE_TYPES.TSDeclareFunction,
68 utils_1.AST_NODE_TYPES.TSExportAssignment,
69 utils_1.AST_NODE_TYPES.TSImportEqualsDeclaration,
70 utils_1.AST_NODE_TYPES.TSTypeAliasDeclaration,
71 utils_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
72 ].reduce((acc, node) => {
73 acc[node] = checkForSemicolon;
74 return acc;
75 }, {});
76 return Object.assign(Object.assign(Object.assign({}, rules), nodesToCheck), { ExportDefaultDeclaration(node) {
77 if (node.declaration.type !== utils_1.AST_NODE_TYPES.TSInterfaceDeclaration) {
78 rules.ExportDefaultDeclaration(node);
79 }
80 } });
81 },
82});
83//# sourceMappingURL=semi.js.map
\No newline at end of file