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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[no-unused-vars] Reports errors on variables used in globally declared TypeScript namespaces #1596
Comments
Can this also explain this rule false-positive on import { assert } from 'chai'
import { jsx } from '../jsx'
describe('snabbdom', function () {
describe('jsx', function () {
it('can be used as a jsxFactory method', function () {
const vnode = <div title="Hello World">Hello World</div>
assert.deepStrictEqual(vnode, {
sel: 'div',
data: { title: 'Hello World' },
children: undefined,
elm: undefined,
text: 'Hello World',
key: undefined
})
})
})
}) |
if anything that's due to the rule not handling jsx. |
@mightyiam you need to add react-jsx eslint plugin to handle this.
.eslintrc.js options
|
Also @mightyiam , the eslint and tslint rules conflict, you have to turn of eslint rule, and enable the corresponding tseslint rule. My config looks like, and I don't see the undefined vars errors you are seeing. function asTsEslintRules(/** @type {Record<String, [string, ...any[]]>} */ rules) {
const tsRules = {};
for (const [rule, ruleOpts] of Object.entries(rules)) {
tsRules[`@typescript-eslint/${rule}`] = ruleOpts;
tsRules[rule] = [`off`];
}
return tsRules;
}
/** @type {Record<String, [string, ...any[]]>} */
const TS_ES_RULES = {
'no-unused-expressions': [`error`, {allowShortCircuit: true, allowTernary: true}],
'no-unused-vars': [`error`, {argsIgnorePattern: `^_`}],
'no-use-before-define': [`error`],
'require-await': [`error`],
camelcase: [`error`],
quotes: [`error`, `backtick`],
};
const TS_OVERRIDE = {
files: [`**/*.ts`, `**/*.tsx`],
parser: `@typescript-eslint/parser`,
parserOptions: {
project: `./tsconfig.json`,
tsconfigRootDir: __dirname,
},
plugins: [`@typescript-eslint`],
extends: [
`eslint:recommended`,
`plugin:@typescript-eslint/eslint-recommended`,
`plugin:@typescript-eslint/recommended`,
`plugin:@typescript-eslint/recommended-requiring-type-checking`,
`prettier`,
`prettier/@typescript-eslint`,
],
rules: {
// these eslint rules conflict with typescript-eslint rules
// we replace the eslint rule with @typescript-eslint/{rule}
...asTsEslintRules(TS_ES_RULES),
'@typescript-eslint/array-type': [`error`, {default: `array-simple`}],
},
}; Also remember to get latest packages. |
Merging into #1856 |
app-server.d.ts
:Expected Result
typescript-eslint/no-unused-vars
should not report an error onNode
not being used.Actual Result
typescript-eslint/no-unused-vars
reports an error onNode
not being used.Additional Info
Works fine when defining the namespace not flobalie:
Versions
@typescript-eslint/eslint-plugin
2.18.0
@typescript-eslint/parser
2.16.0
TypeScript
^3.7.4
ESLint
^6.8.0
node
v12.14.1
npm
6.13.4
The text was updated successfully, but these errors were encountered: