Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
fix(eslint-plugin): support eslint@5#2917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -46,6 +46,7 @@ | ||
| "@typescript-eslint/scope-manager":"4.12.0", | ||
| "debug":"^4.1.1", | ||
| "functional-red-black-tree":"^1.0.1", | ||
| "lodash":"^4.17.15", | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
| ||
| "regexpp":"^3.0.0", | ||
| "semver":"^7.3.2", | ||
| "tsutils":"^3.17.1" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -13,43 +13,6 @@ type Options = [ | ||
| }, | ||
| ]; | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. my IDE "complained" about duplicate code, so I found this and just removed it | ||
| export default util.createRule<Options, MessageIds>({ | ||
| name: 'no-redeclare', | ||
| meta: { | ||
| @@ -129,7 +92,7 @@ export default util.createRule<Options, MessageIds>({ | ||
| yield { | ||
| type: 'comment', | ||
| node: comment, | ||
| loc:util.getNameLocationInGlobalDirectiveComment( | ||
| sourceCode, | ||
| comment, | ||
| variable.name, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,43 @@ | ||
| import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils'; | ||
| import escapeRegExp from 'lodash/escapeRegExp'; | ||
| // deeply re-export, for convenience | ||
| export * from '@typescript-eslint/experimental-utils/dist/ast-utils'; | ||
| // The following is copied from `eslint`'s source code since it doesn't exist in eslint@5. | ||
| // https://github.com/eslint/eslint/blob/145aec1ab9052fbca96a44d04927c595951b1536/lib/rules/utils/ast-utils.js#L1751-L1779 | ||
| // Could be export { getNameLocationInGlobalDirectiveComment } from 'eslint/lib/rules/utils/ast-utils' | ||
| /** | ||
| * Get the `loc` object of a given name in a `/*globals` directive comment. | ||
| * @param {SourceCode} sourceCode The source code to convert index to loc. | ||
| * @param {Comment} comment The `/*globals` directive comment which include the name. | ||
| * @param {string} name The name to find. | ||
| * @returns {SourceLocation} The `loc` object. | ||
| */ | ||
| export function getNameLocationInGlobalDirectiveComment( | ||
| sourceCode: TSESLint.SourceCode, | ||
| comment: TSESTree.Comment, | ||
| name: string, | ||
| ): TSESTree.SourceLocation { | ||
| const namePattern = new RegExp( | ||
| `[\\s,]${escapeRegExp(name)}(?:$|[\\s,:])`, | ||
| 'gu', | ||
| ); | ||
| // To ignore the first text "global". | ||
| namePattern.lastIndex = comment.value.indexOf('global') + 6; | ||
| // Search a given variable name. | ||
| const match = namePattern.exec(comment.value); | ||
| // Convert the index to loc. | ||
| const start = sourceCode.getLocFromIndex( | ||
| comment.range[0] + '/*'.length + (match ? match.index + 1 : 0), | ||
| ); | ||
| const end = { | ||
| line: start.line, | ||
| column: start.column + (match ? name.length : 1), | ||
| }; | ||
| return { start, end }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -830,17 +830,3 @@ declare module 'eslint/lib/rules/prefer-const' { | ||
| >; | ||
| export = rule; | ||
| } | ||