Skip to content
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

Key used in keypath are reported unused #251

Closed
xibman opened this issue Oct 29, 2021 · 0 comments · Fixed by #252
Closed

Key used in keypath are reported unused #251

xibman opened this issue Oct 29, 2021 · 0 comments · Fixed by #252

Comments

@xibman
Copy link

xibman commented Oct 29, 2021

Tell us about your environment

  • ESLint version: ^8.1.0
  • eslint-plugin-vue version: ^7.20.0
  • eslint-plugin-vue-i18n version: 1.0.0 and also 0.15.0
  • Node version: v14.17.6 or 16.13.0
  • Vue-i18n: ^9.1.9

Please show your full configuration:

module.exports = {
  env: {
    node: true,
  },
  extends: [
    'plugin:vue/vue3-recommended',
    '@vue/airbnb',
    '@vue/typescript/recommended',
    '@vue/prettier',
    '@vue/prettier/@typescript-eslint',
    'plugin:@intlify/vue-i18n/recommended',
    'plugin:jsonc/recommended-with-jsonc',
  ],
  ignorePatterns: ['tailwind.config.js', 'postcss.config.js', 'package.json'],
  overrides: [
    {
      env: {
        jest: true,
      },
      files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/unit/**/*.spec.{j,t}s?(x)'],
    },
  ],
  parserOptions: {
    ecmaVersion: 2020,
  },
  plugins: ['simple-import-sort'],
  root: true,
  rules: {
    '@intlify/vue-i18n/key-format-style': [
      'error',
      'camelCase',
      {
        allowArray: false,
      },
    ],
    '@intlify/vue-i18n/no-unused-keys': [
      'error',
      {
        extensions: ['.js', '.vue', '.ts', 'json'],
        src: './src',
      },
    ],
    '@typescript-eslint/no-shadow': 'error',
    '@typescript-eslint/no-var-requires': 'off',
    'global-require': 'off',
    'import/no-dynamic-require': 'off',
    'jsonc/sort-keys': [
      'error',
      'asc',
      {
        caseSensitive: true,

        minKeys: 2,
        natural: false,
      },
    ],
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-shadow': 'off',
    'simple-import-sort/exports': 'error',
    'simple-import-sort/imports': [
      'error',
      {
        groups: [
          [
            '^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)',
          ],
          // Packages. `react` related packages come first.
          ['^react', '^@?\\w'],
          // Internal packages.
          ['^(@|@src|@test|@company|@ui|components|utils|config|vendored-lib)(/.*|$)'],
          // Side effect imports.
          ['^\\u0000'],
          // Parent imports. Put `..` last.
          ['^\\.\\.(?!/?$)', '^\\.\\./?$'],
          // Other relative imports. Put same-folder imports and `.` last.
          ['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
          // Style imports.
          ['^.+\\.s?css$'],
        ],
      },
    ],
    'vue/block-lang': [
      'error',
      {
        script: {
          lang: 'ts',
        },
      },
    ],
    'vue/component-name-in-template-casing': [
      'error',
      'PascalCase',
      {
        ignores: [],
        registeredComponentsOnly: true,
      },
    ],
    'vue/html-button-has-type': [
      'error',
      {
        button: true,
        reset: true,
        submit: true,
      },
    ],
    'vue/match-component-file-name': [
      'error',
      {
        extensions: ['jsx'],
        shouldMatchCase: false,
      },
    ],
    'vue/no-duplicate-attr-inheritance': 'error',
    'vue/no-empty-component-block': 'error',
    'vue/no-reserved-component-names': 'error',
    'vue/no-unregistered-components': [
      'error',
      {
        ignorePatterns: ['router(\\-\\w+)+', 'i18n(\\-\\w+)+'],
      },
    ],
    'vue/no-unused-properties': 'error',
    'vue/no-unused-refs': 'error',
    'vue/padding-line-between-blocks': ['error', 'always'],
    'vue/require-name-property': 'error',
    'vue/sort-keys': [
      'error',
      'asc',
      {
        caseSensitive: true,
        ignoreChildrenOf: ['model'],
        ignoreGrandchildrenOf: ['computed', 'directives', 'inject', 'props', 'watch'],
        minKeys: 2,
        natural: false,
      },
    ],
    'vue/v-on-event-hyphenation': [
      'error',
      'always',
      {
        autofix: true,
        ignore: [],
      },
    ],
  },

  settings: {
    'vue-i18n': {
      localeDir: {
        localeKey: 'file',
        pattern: './src/locales/*.{json,json5,yaml,yml}',
      },
      messageSyntaxVersion: '^9.0.0',
    },
  },
};

What did you do?

<i18n-t keypath="pages.form.content1" tag="p">
      <template #compensation>
        <span class="bg-emerald-500 font-bold">{{ compensation }}</span>
      </template>
    </i18n-t>

What did you expect to happen?
The key pages.form.content1 is used in the keypath so must not be reported as unused by eslint

If prop 'path' is used no reports. But with vue-i18n next this props is deprecated.
What actually happened?

error unused 'pages.form.content1' key @intlify/vue-i18n/no-unused-keys

Thanks for your work !!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant