UNPKG

eslint-codemod-utils

Version:

A collection of AST helper functions for more complex ESLint rule fixes.

1,225 lines 223 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = { type: 'Program', start: 0, end: 1387, loc: { start: { line: 1, column: 0, }, end: { line: 99, column: 0, }, }, range: [0, 1387], comments: [ { type: 'Line', value: ' hello', start: 425, end: 433, loc: { start: { line: 21, column: 0, }, end: { line: 21, column: 8, }, }, range: [425, 433], }, ], sourceType: 'module', body: [ { type: 'ImportDeclaration', start: 0, end: 47, loc: { start: { line: 1, column: 0, }, end: { line: 1, column: 47, }, }, range: [0, 47], specifiers: [ { type: 'ImportDefaultSpecifier', start: 7, end: 8, loc: { start: { line: 1, column: 7, }, end: { line: 1, column: 8, }, }, range: [7, 8], local: { type: 'Identifier', start: 7, end: 8, loc: { start: { line: 1, column: 7, }, end: { line: 1, column: 8, }, }, range: [7, 8], name: 'A', }, }, { type: 'ImportSpecifier', start: 12, end: 19, loc: { start: { line: 1, column: 12, }, end: { line: 1, column: 19, }, }, range: [12, 19], imported: { type: 'Identifier', start: 12, end: 19, loc: { start: { line: 1, column: 12, }, end: { line: 1, column: 19, }, }, range: [12, 19], name: 'Welcome', }, local: { type: 'Identifier', start: 12, end: 19, loc: { start: { line: 1, column: 12, }, end: { line: 1, column: 19, }, }, range: [12, 19], name: 'Welcome', }, }, ], source: { type: 'Literal', start: 27, end: 46, loc: { start: { line: 1, column: 27, }, end: { line: 1, column: 46, }, }, range: [27, 46], value: '@atlaskit/welcome', raw: "'@atlaskit/welcome'", }, }, { type: 'ImportDeclaration', start: 48, end: 75, loc: { start: { line: 2, column: 0, }, end: { line: 2, column: 27, }, }, range: [48, 75], specifiers: [ { type: 'ImportSpecifier', start: 57, end: 58, loc: { start: { line: 2, column: 9, }, end: { line: 2, column: 10, }, }, range: [57, 58], imported: { type: 'Identifier', start: 57, end: 58, loc: { start: { line: 2, column: 9, }, end: { line: 2, column: 10, }, }, range: [57, 58], name: 'X', }, local: { type: 'Identifier', start: 57, end: 58, loc: { start: { line: 2, column: 9, }, end: { line: 2, column: 10, }, }, range: [57, 58], name: 'X', }, }, ], source: { type: 'Literal', start: 66, end: 75, loc: { start: { line: 2, column: 18, }, end: { line: 2, column: 27, }, }, range: [66, 75], value: './other', raw: "'./other'", }, }, { type: 'ImportDeclaration', start: 76, end: 107, loc: { start: { line: 3, column: 0, }, end: { line: 3, column: 31, }, }, range: [76, 107], specifiers: [ { type: 'ImportDefaultSpecifier', start: 83, end: 86, loc: { start: { line: 3, column: 7, }, end: { line: 3, column: 10, }, }, range: [83, 86], local: { type: 'Identifier', start: 83, end: 86, loc: { start: { line: 3, column: 7, }, end: { line: 3, column: 10, }, }, range: [83, 86], name: 'tmm', }, }, { type: 'ImportNamespaceSpecifier', start: 88, end: 94, loc: { start: { line: 3, column: 12, }, end: { line: 3, column: 18, }, }, range: [88, 94], local: { type: 'Identifier', start: 93, end: 94, loc: { start: { line: 3, column: 17, }, end: { line: 3, column: 18, }, }, range: [93, 94], name: 'x', }, }, ], source: { type: 'Literal', start: 100, end: 107, loc: { start: { line: 3, column: 24, }, end: { line: 3, column: 31, }, }, range: [100, 107], value: 'thing', raw: "'thing'", }, }, { type: 'ImportDeclaration', start: 108, end: 121, loc: { start: { line: 4, column: 0, }, end: { line: 4, column: 13, }, }, range: [108, 121], specifiers: [], source: { type: 'Literal', start: 115, end: 121, loc: { start: { line: 4, column: 7, }, end: { line: 4, column: 13, }, }, range: [115, 121], value: 'blah', raw: "'blah'", }, }, { type: 'VariableDeclaration', start: 122, end: 159, loc: { start: { line: 5, column: 0, }, end: { line: 5, column: 37, }, }, range: [122, 159], declarations: [ { type: 'VariableDeclarator', start: 128, end: 159, loc: { start: { line: 5, column: 6, }, end: { line: 5, column: 37, }, }, range: [128, 159], id: { type: 'Identifier', start: 128, end: 138, loc: { start: { line: 5, column: 6, }, end: { line: 5, column: 16, }, }, range: [128, 138], name: 'someImport', }, init: { type: 'ImportExpression', start: 141, end: 159, loc: { start: { line: 5, column: 19, }, end: { line: 5, column: 37, }, }, range: [141, 159], source: { type: 'Literal', start: 148, end: 158, loc: { start: { line: 5, column: 26, }, end: { line: 5, column: 36, }, }, range: [148, 158], value: 'hello.js', raw: "'hello.js'", }, }, }, ], kind: 'const', }, { type: 'VariableDeclaration', start: 161, end: 197, loc: { start: { line: 7, column: 0, }, end: { line: 7, column: 36, }, }, range: [161, 197], declarations: [ { type: 'VariableDeclarator', start: 167, end: 197, loc: { start: { line: 7, column: 6, }, end: { line: 7, column: 36, }, }, range: [167, 197], id: { type: 'Identifier', start: 167, end: 180, loc: { start: { line: 7, column: 6, }, end: { line: 7, column: 19, }, }, range: [167, 180], name: 'someStatement', }, init: { type: 'ChainExpression', start: 183, end: 197, loc: { start: { line: 7, column: 22, }, end: { line: 7, column: 36, }, }, range: [183, 197], expression: { type: 'MemberExpression', start: 183, end: 197, loc: { start: { line: 7, column: 22, }, end: { line: 7, column: 36, }, }, range: [183, 197], object: { type: 'Identifier', start: 183, end: 191, loc: { start: { line: 7, column: 22, }, end: { line: 7, column: 30, }, }, range: [183, 191], name: 'probably', }, computed: false, property: { type: 'Identifier', start: 193, end: 197, loc: { start: { line: 7, column: 32, }, end: { line: 7, column: 36, }, }, range: [193, 197], name: 'blob', }, optional: true, }, }, }, ], kind: 'const', }, { type: 'FunctionDeclaration', start: 199, end: 400, loc: { start: { line: 9, column: 0, }, end: { line: 17, column: 1, }, }, range: [199, 400], id: { type: 'Identifier', start: 208, end: 211, loc: { start: { line: 9, column: 9, }, end: { line: 9, column: 12, }, }, range: [208, 211], name: 'App', }, generator: false, async: false, expression: false, params: [ { type: 'ObjectPattern', start: 212, end: 217, loc: { start: { line: 9, column: 13, }, end: { line: 9, column: 18, }, }, range: [212, 217], properties: [ { type: 'Property', start: 214, end: 215, loc: { start: { line: 9, column: 15, }, end: { line: 9, column: 16, }, }, range: [214, 215], key: { type: 'Identifier', start: 214, end: 215, loc: { start: { line: 9, column: 15, }, end: { line: 9, column: 16, }, }, range: [214, 215], name: 'a', }, computed: false, method: false, shorthand: true, value: { type: 'Identifier', start: 214, end: 215, loc: { start: { line: 9, column: 15, }, end: { line: 9, column: 16, }, }, range: [214, 215], name: 'a', }, kind: 'init', }, ], }, { type: 'ObjectPattern', start: 219, end: 227, loc: { start: { line: 9, column: 20, }, end: { line: 9, column: 28, }, }, range: [219, 227], properties: [ { type: 'Property', start: 221, end: 225, loc: { start: { line: 9, column: 22, }, end: { line: 9, column: 26, }, }, range: [221, 225], key: { type: 'Identifier', start: 221, end: 222, loc: { start: { line: 9, column: 22, }, end: { line: 9, column: 23, }, }, range: [221, 222], name: 'b', }, computed: false, method: false, shorthand: false, value: { type: 'Identifier', start: 224, end: 225, loc: { start: { line: 9, column: 25, }, end: { line: 9, column: 26, }, }, range: [224, 225], name: 'c', }, kind: 'init', }, ], }, ], body: { type: 'BlockStatement', start: 229, end: 400, loc: { start: { line: 9, column: 30, }, end: { line: 17, column: 1, }, }, range: [229, 400], body: [ { type: 'ReturnStatement', start: 233, end: 398, loc: { start: { line: 10, column: 2, }, end: { line: 16, column: 4, }, }, range: [233, 398], argument: { type: 'JSXElement', start: 246, end: 393, loc: { start: { line: 11, column: 4, }, end: { line: 15, column: 10, }, }, range: [246, 393], openingElement: { type: 'JSXOpeningElement', start: 246, end: 251, loc: { start: { line: 11, column: 4, }, end: { line: 11, column: 9, }, }, range: [246, 251], name: { type: 'JSXIdentifier', start: 247, end: 250, loc: { start: { line: 11, column: 5, }, end: { line: 11, column: 8, }, }, range: [247, 250], name: 'div', }, attributes: [], selfClosing: false, }, closingElement: { type: 'JSXClosingElement', start: 387, end: 393, loc: { start: { line: 15, column: 4, }, end: { line: 15, column: 10, }, }, range: [387, 393], name: { type: 'JSXIdentifier', start: 389, end: 392, loc: { start: { line: 15, column: 6, }, end: { line: 15, column: 9, }, }, range: [389, 392], name: 'div', }, }, children: [ { type: 'JSXText', start: 251, end: 258, loc: { start: { line: 11, column: 9, }, end: { line: 12, column: 6, }, }, range: [251, 258], value: '\n ', raw: '\n ', }, { type: 'JSXElement', start: 258, end: 320, loc: { start: { line: 12, column: 6, }, end: { line: 12, column: 68, }, }, range: [258, 320], openingElement: { type: 'JSXOpeningElement', start: 258, end: 320, loc: { start: { line: 12, column: 6, }, end: { line: 12, column: 68, }, }, range: [258, 320], name: { type: 'JSXIdentifier', start: 259, end: 266, loc: { start: { line: 12, column: 7, }, end: { line: 12, column: 14, }, }, range: [259, 266], name: 'Welcome', }, attributes: [ { type: 'JSXAttribute', start: 267, end: 278, loc: { start: { line: 12, column: 15, }, end: { line: 12, column: 26, }, }, range: [267, 278], name: { type: 'JSXIdentifier', start: 267, end: 271, loc: { start: { line: 12, column: 15, }, end: { line: 12, column: 19, }, }, range: [267, 271], name: 'name', }, value: { type: 'Literal', start: 272, end: 278, loc: { start: { line: 12, column: 20, }, end: { line: 12, column: 26, }, }, range: [272, 278], value: 'Sara', raw: '"Sara"', }, }, { type: 'JSXAttribute', start: 279, end: 292, loc: { start: { line: 12, column: 27, }, end: { line: 12, column: 40, }, }, range: [279, 292], name: { type: 'JSXIdentifier', start: 279, end: 288, loc: { start: { line: 12, column: 27, }, end: { line: 12, column: 36, }, }, range: [279, 288], name: 'otherName', }, value: { type: 'JSXExpressionContainer', start: 289, end: 292, loc: { start: { line: 12, column: 37, }, end: { line: 12, column: 40, }, }, range: [289, 292], expression: { type: 'Literal', start: 290, end: 291, loc: { start: { line: 12, column: 38, }, end: { line: 12, column: 39, }, }, range: [290, 291], value: 2, raw: '2', }, }, }, { type: 'JSXAttribute', start: 293, end: 308, loc: { start: { line: 12, column: 41, }, end: { line: 12, column: 56, }, }, range: [293, 308], name: { type: 'JSXIdentifier', start: 293, end: 308, loc: { start: { line: 12, column: 41, }, end: { line: 12, column: 56, }, }, range: [293, 308], name: 'isBlanketHidden', }, value: null, }, { type: 'JSXSpreadAttribute', start: 309, end: 317, loc: { start: { line: 12, column: 57, }, end: { line: 12, column: 65, }, }, range: [309, 317], argument: { type: 'CallExpression', start: 313, end: 316, loc: { start: { line: 12, column: 61, }, end: { line: 12, column: 64, }, }, range: [313, 316], callee: { type: 'Identifier', start: 313, end: 314, loc: { start: { line: 12, column: 61, }, end: { line: 12, column: 62, }, }, range: [313, 314], name: 'x', }, arguments: [], optional: false, }, }, ], selfClosing: true, }, closingElement: null, children: [], }, { type: 'JSXText', start: 320, end: 327, loc: { start: { line: 12, column: 68, }, end: { line: 13, column: 6, }, }, range: [320, 327], value: '\n ', raw: '\n ', }, { type: 'JSXElement', start: 327, end: 351, loc: { start: { line: 13, column: 6, }, end: { line: 13, column: 30, }, }, range: [327, 351], openingElement: { type: 'JSXOpeningElement', start: 327, end: 351, loc: { start: { line: 13, column: 6, }, end: { line: 13, column: 30, }, }, range: [327, 351], name: { type: 'JSXIdentifier', start: 328, end: 335, loc: { start: { line: 13, column: 7, }, end: { line: 13, column: 14, }, }, range: [328, 335], name: 'Welcome', }, attributes: [ { type: 'JSXAttribute