Code Monkey home page Code Monkey logo

eslint-plugin-canonical's People

Contributors

brettz9 avatar gajus avatar luis721 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

eslint-plugin-canonical's Issues

[Feature request] virtual-module feature should allow for nested virtual modules

Bug report or Feature request?

Feature request

Information

virtual-module feature should allow for nested virtual modules
a parent virtual modules should be able to re-export members from nested - child - virtual modules

components/
├── Foo/
│ └── index.ts
│ └── Qux/
│ └── index.ts/
│ └── Quux/
│ └── index.ts
└── Bar

Qux should be able to re-export from Quux
Foo should be able to re-export from Qux
Bar should be able to import from Foo

if specific members of Quux are re-exported by Qux
and
same specific members are re-exported by Foo
then
Bar should be able to import them from Foo

currently, this is not supported as we get
Cannot import a private path. /index.ts belongs to parent virtual module
when re-exporting from nested virtual module

Cannot find module 'lodash' when using PNPM

Hey, I was checking out the eslint-config-canonical package and came across this.

lodash is being imported at runtime by rules/filenameMatchExported.js, but it's not listed in dependencies.

This turn into a problem when using PNPM as package manager for the project, because the node_modules layout it creates doesn't let eslint-plugin-canonical have access to lodash.

Oops! Something went wrong! :(

ESLint: 8.6.0

Error: Failed to load plugin 'canonical' declared in '.eslintrc.yaml » eslint-config-canonical': Cannot find module 'lodash'
Require stack:
- /project/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint-plugin-canonical/dist/rules/filenameMatchExported.js
- /project/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint-plugin-canonical/dist/index.js
- /project/node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (/project/node_modules/.pnpm/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/project/node_modules/.pnpm/[email protected][email protected]/node_modules/eslint-plugin-canonical/dist/rules/filenameMatchExported.js:10:15)
    at Module._compile (/project/node_modules/.pnpm/[email protected]/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)

invalid recommended config

Error: .eslintrc.js » plugin:canonical/recommended:
        Configuration for rule "canonical/id-match" is invalid:
        Value {"caseSensitive":false,"natural":true,"classFields":false,"ignoreDestructuring":false,"ignoreNamedImports":false,"onlyDeclarations":false,"properties":false} should NOT have additional properties.

This same typo is also present in README Configuration section.

Current Version on NPM is 2.6.0

From looking at https://www.npmjs.com/package/eslint-plugin-canonical (specifically the "Versions" tab), you can see that 2.6.0 is tagged as the latest version. I'm not sure what version (or state of the repo) this version actually maps to, but at the very least, it doesn't include the new prefer-inline-type-import rule (which is how I noticed this). Should the latest version (the version that NPM "installs" by default) not be 3.0.0?

id-match ignore all imports

It would be nice to be able to ignore all imports. For example:

'canonical/id-match': ['error', '^[a-z]+([A-Z][a-z]+)*$', {
      ignoreImports: true,
}]

Would allow

import React from 'react'

Kebab filename export for react components

Is there any chance to add an ability to have kebab filename for pascal type of export (react component)?

Rule sample:
"canonical/filename-match-exported": [ 2, { "transforms": "kebab" } ]

Filename sample:
thumb-up.tsx

Export sample:
export default ThumbUp

Current state:
Error:
1:1 error Filename 'thumb-up' must match the exported and transformed name 'thumbUp' canonical/filename-match-exported

Expected: No error

3.2.1: Definition for rule 'canonical/...' was not found

👋 @gajus!

I faced an odd issue with this plugin after upgrading ESLint dependencies in hashintel/hash#1796 via Renovate. CI output was full of errors like:

  1:1  error  Definition for rule 'canonical/filename-no-index' was not found  canonical/filename-no-index

/home/runner/work/hash/hash/packages/hash/frontend/src/components/page-icon.tsx
  1:1  error  Definition for rule 'canonical/filename-no-index' was not found  canonical/filename-no-index

/home/runner/work/hash/hash/packages/hash/frontend/src/components/page-loading-state.tsx
  1:1  error  Definition for rule 'canonical/filename-no-index' was not found  canonical/filename-no-index

/home/runner/work/hash/hash/packages/hash/frontend/src/components/remote-block/block-renderer.tsx
  1:1  error  Definition for rule 'canonical/filename-no-index' was not found  canonical/filename-no-index

/home/runner/work/hash/hash/packages/hash/frontend/src/components/remote-block/block-renderer/custom-element.tsx
  1:1  error  Definition for rule 'canonical/filename-no-index' was not found  canonical/filename-no-index

/home/runner/work/hash/hash/packages/hash/frontend/src/components/remote-block/block-renderer/html.tsx
  1:1  error  Definition for rule 'canonical/filename-no-index' was not found  canonical/filename-no-index

/home/runner/work/hash/hash/packages/hash/frontend/src/components/remote-block/loadremote-block.ts
  1:1  error  Definition for rule 'canonical/filename-no-index' was not found  canonical/filename-no-index

/home/runner/work/hash/hash/packages/hash/frontend/src/components/remote-block/remote-block.tsx
  1:1  error  Definition for rule 'canonical/filename-no-index' was not found  canonical/filename-no-index

After downgrading eslint-plugin-canonical from 3.2.1 back to 3.1.0, CI went back to normal.

I did not investigate this case further, but I still decided to open an issue to potentially help other folks. Feel free to close it if I’ve missed something!

Reduce dependencies

After moving eslint-plugin-filenames -> eslint-plugin-canonical, I found that the volume of linting dependencies has almost doubled from what it was - but it was dependencies of eslint with 14 heavy plugins.

zloirock/core-js@3e58c09, see tests/eslint/package-lock.json.

Is it possible somehow reduce it?

Reason for changing the parser

Hi,

the README says:

Set parser property to babel-eslint.

what is the reason for that?

I haven't changed the default parser and it seems your plugin can detect errors already.

`filename-match-exported` doesn’t support `null` in the `transforms` array

The readme currently says that you can use:

"canonical/filename-match-exported": [2, { "transforms": [ null, "kebab", "snake" ] } ]

This doesn’t actually work, because the config schema only supports strings in the transforms array. ESLint crashes with an error.

You can work around this today by adding any string outside of the normal config map to the array, like so:

"canonical/filename-match-exported": [2, { "transforms": [ "null", "kebab", "snake" ] } ]

This causes the plugin to resolve that transform to undefined, which it treats the same as null for the purposes of transforming.

Just raising the issue so you’re aware of it. This is probably extremely low priority.

2.6.0 release to undo 2.5.0

@gajus : Although I see you've since moved to a 3.0.0 version, a 2.5.0 version of eslint-plugin-canonical was nevertheless released with breaking changes (the node: specifiers). This causes all projects targeting ^2.0.0, such as eslint-plugin-jsdoc to suddenly start breaking.

Could you put out a 2.6.0 release which reverts those node: changes, as the EOL that is coming at the end of this month is only to drop Node 12, not yet to drop Node 14?

Thanks!

[`prefer-inline-type-import`] Edge Cases Currently Not Handled

After trying to add this rule to my work codebase, I encountered the following cases where there was no easy way to resolve the lint warnings:

  1. Importing a default export and only using its type. There are a few cases where default exports can't be avoided - for example, importing the type of a JSON file (import type package from "./package.json";), or a library import than you don't control. In this case, I would personally expect the rule to accept this as valid.
  2. Glob type-only imports, for example, import type * as Types from "./types";. While this is something that can more easily be worked around compared to the case above (by just explicitly importing the required types), I do still think it is something the rule should handle. As with the above case, I would personally expect the rule to accept this as valid (even if it is via an option).

id-match rule issue

The id-match rule is erring out with this code:

       const {
          index,
          '0': n0,
          '1': n1,
        } = exampleCode;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.