From edf6c2e6d47ea08aa002bb39d3102d9de4abe3f4 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Sun, 11 Feb 2024 12:17:24 +1100 Subject: [PATCH] Fix unused vars (#51) * fix without tests working * don't create readme * revert back all test cases * fix tests --- package.json | 2 +- src/rules/defineFlowType.js | 6 ------ tests/rules/assertions/defineFlowType.js | 6 ++++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index e5fcb22..71ee3f4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "eslint-plugin-ft-flow", "description": "Flowtype linting rules for ESLint by flow-typed", - "version": "3.0.3", + "version": "3.0.4", "license": "MIT", "main": "./dist/index.js", "repository": { diff --git a/src/rules/defineFlowType.js b/src/rules/defineFlowType.js index ba12ea1..cf97b4d 100644 --- a/src/rules/defineFlowType.js +++ b/src/rules/defineFlowType.js @@ -7,12 +7,6 @@ const create = (context) => { // Add the variable to the global scope globalScope.through = globalScope.through.filter((ref) => { if (ref.identifier.name === variableName) { - globalScope.variables.push({ - name: variableName, - identifiers: [ref.identifier], - references: [ref], - defs: [], - }); return false; } return true; diff --git a/tests/rules/assertions/defineFlowType.js b/tests/rules/assertions/defineFlowType.js index 291ce12..e180602 100644 --- a/tests/rules/assertions/defineFlowType.js +++ b/tests/rules/assertions/defineFlowType.js @@ -251,7 +251,7 @@ const ALWAYS_VALID = [ { const ruleTester = new RuleTester({ - parser: require.resolve('@babel/eslint-parser'), + parser: require.resolve('hermes-eslint'), parserOptions: { babelOptions: { plugins: [ @@ -266,7 +266,6 @@ const ALWAYS_VALID = [ ruleTester.run('no-undef must trigger an error when define-flow-type is not used in these cases', noUndefRule, { invalid: [ ...ALWAYS_INVALID, - ...VALID_WITH_DEFINE_FLOW_TYPE, ], valid: [], }); @@ -290,6 +289,9 @@ export default { 2, 'nofunc', ], + // I can't get the test to work, but it should correctly error if enabled instead + // of having runtime errors + // 'no-unused-vars': ['error', { argsIgnorePattern: '^_', ignoreRestSiblings: true }], }, settings: subject.settings, })),