Giter Club home page Giter Club logo

code-quality-tools's People

Contributors

andrenanninga avatar arnostpleskot avatar bsunderhus avatar dannytce avatar dependabot-preview[bot] avatar dependabot[bot] avatar developer239 avatar honzahovorka avatar jozefcipa avatar lekterable avatar lucasconstantino avatar matejpolak avatar petrkonecny2 avatar prichodko avatar robertrossmann avatar ruanmartinelli 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-quality-tools's Issues

Update commands in docs

Hey, I came across to this during installation, so just FYI :]

Current:

# Yarn:
yarn add --dev @strv/stylelint-config

# npm:
npm install --save-dev @strv/stylelint-config

Expected:

# Yarn:
yarn add --dev @strv/stylelint-config-styled-components

# npm:
npm install --save-dev @strv/stylelint-config-styled-components

[eslint-config-base] Configuration for rule "import/no-useless-path-segments" is invalid

If I manage to add either @strv/react-native/style or @strv/eslint-config-typescript/style to my .eslintrc, I get this error:

Error: ../../.eslintrc.js ยป @strv/eslint-config-react-native/style ยป /Users/matheusalbuquerque/Documents/dev/strv/goulash-club/Repos/goulash-club-frontend/node_modules/@strv/eslint-config-react/style.js ยป /Users/matheusalbuquerque/Documents/dev/strv/goulash-club/Repos/goulash-club-frontend/node_modules/@strv/eslint-config-base/style.js:
	Configuration for rule "import/no-useless-path-segments" is invalid:
	Value {"noUselessIndex":true} should NOT have additional properties.

I checked the source and it seems to be just like to documentation reccomends โ€“ so, for now, I don't have any clue ๐Ÿ˜ž .

Dependabot can't resolve your JavaScript dependency files

Dependabot can't resolve your JavaScript dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Error whilst updating eslint-plugin-mocha in /packages/eslint-config-mocha/package-lock.json:
404 Not Found - GET https://registry.npmjs.org/@strv/eslint-config-base - Not found

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Possible improvements [config-react-native]

Hello ๐Ÿ‘‹
this is the third batch of possible improvements.

Missing rules:

This one is complete. ๐ŸŽ‰ ๐ŸŽ‰

Rules that I would change:
Mostly config code style improvement so feel free to ignore.

Textlint Github Action

Let's create an action that could be used on our repositories regardless if it's a frontend, backend, or any other (non-javascript) platform!

The idea is simple - to minify typos and silly grammar mistakes from our readmes, ADRs and any other markdown related content :)


@robertrossmann a quick question for you - do you think that this monorepo is a good place where to add our own github actions? Or shall we create them in a separate repository?

Standalone repository make sense in terms of easier usage.
This monorepo make sense to have everything together under one roof.

Add Dependabot

Let's install Greenkeeper or a similar service to get an automatical update of dependencies.

For example, eslint-plugin-import is out of date. And it doesn't work well with @typescript-eslint/parser, which throws errors on types and interfaces for import/named rule

Transition to eslint-plugin-jsdoc

JSDoc rules in ESLint have been deprecated.

We might want to move to eslint-plugin-jsdoc via a new configuration file in the eslint-config-base ruleset (JSDoc validation might be useful in all JS environments, including Node, React, RN, and TypeScript).

Enable valid-jsdoc for TS

The valid-jsdoc could be enabled for TypeScript but with a different configuration, especially the requireParamType should be disabled. Further modifications may be applied.

@typescript-eslint/interface-name-prefix violates encapsulations principles

Reason 1 - The times of the Hungarian notation have passed

The main argument from I-prefix-for-interface supporters is that prefixing is helpful for immediately grokking (peeking) whether a type is an interface. A statement that prefix is helpful for immediately grokking (peeking) is an appeal to Hungarian notation. I prefix for interface name, C for class, A for abstract class, s for a string variable, c for const variable, i for integer variable. I agree that such name decoration can provide you type information without hovering mouse over identifier or navigating to type definition via a hot-key. This tiny benefit is outweighed by Hungarian notation disadvantages and other reasons mentioned below. Hungarian notation is not used in contemporary frameworks. C#, for example, has I prefix (and this the only prefix in C#) for interfaces due to historical reasons (COM). In retrospect one of the .NET architects (Brad Abrams) thinks it would have been better not using I prefix. TypeScript is COM-legacy-free thereby it shouldn't have an I-prefix-for-interface rule.

Reason 2 - I-prefix violates encapsulation principle

Let's assume you get some black-box. You get some type reference that allows you to interact with that box. You should not care if it is an interface or a class. You just use its interface part. Demanding to know what is it (interface, specific implementation or abstract class) is a violation of encapsulation.

Example: let's assume you need to fix API Design Myth: Interface as Contract in your code e.g. delete ICar interface and use Car base-class instead. Then you need to perform such replacement in all consumers. I-prefix leads to an implicit dependency of consumers on black-box implementation details.

Reason 3 - Protection from bad naming

Developers are lazy to think properly about names. Naming is one of the Two Hard Things in Computer Science. When a developer needs to extract an interface it is easy to just add the letter I to the class name and you get an interface name. Disallowing I prefix for interfaces forces developers to strain their brains to choose appropriate names for interfaces. Chosen names should be different not only in prefix but emphasize intent difference.

Abstraction case: you should not define an ICar interface and an associated Car class. Car is an abstraction and it should be the one used for the contract. Implementations should have descriptive, distinctive names e.g. SportsCar, SuvCar, HollowCar.

Good example: WpfeServerAutosuggestManager implements AutosuggestManager, FileBasedAutosuggestManager implements AutosuggestManager.

Bad example: AutosuggestManager implements IAutosuggestManager.

Reason 4 - Properly chosen names vaccinate you against API Design Myth: Interface as Contract.

In my practice, I met a lot of people that thoughtlessly duplicated interface part of a class in a separate interface having Car implements ICar naming scheme. Duplicating interface part of a class in separate interface type does not magically convert it into abstraction. You will still get concrete implementation but with duplicated interface part. If your abstraction is not so good, duplicating interface part will not improve it anyhow. Extracting abstraction is hard work.

All these reasons were presented by Stanislav Berkov
on StackOverFlow as a repetition from some of the important heads of Microsoft and Oracle about how using this pattern was a bad idea.

Possible improvements [config-react]

Hello ๐Ÿ‘‹
this is the second batch of possible improvements.

Missing rules:

Rules that I would change:
Mostly config code style improvement so feel free to ignore.

move away from Lerna

Lerna has been marked as no longer maintained, we need to move away to a different monorepo management tool. โš ๏ธ

@typescript-eslint/explicit-function-return-type vs inference

@typescript-eslint/explicit-function-return-type enforces every function defines a returning type. Most of the time, though, TypeScript can infer the returning type from the return value. This rules causes many redundant and unnecessary code.

'@typescript-eslint/explicit-function-return-type': ['warn', {
allowExpressions: true,
}],

Ref.: typescript-eslint/typescript-eslint#434

Add commitizen

When you commit with Commitizen, you'll be prompted to fill out any required commit fields at commit time. No more waiting until later for a git commit hook to run and reject your commit (though that can still be helpful). No more digging through CONTRIBUTING.md to find what the preferred format is. Get instant feedback on your commit message formatting and be prompted for required fields.
https://github.com/commitizen/cz-cli

  • Can be used as prepare-commit-msg
  • We can apply it both for this repository and as commitlint package's recommended extension

Possible improvements [config-typescript]

Hello ๐Ÿ‘‹
last update.

party

Missing rules:

Missing plugins:

Missing rules from missing plugins:

  • unused-imports/no-unused-imports 0
  • unused-imports/no-unused-imports-ts 2
  • unused-imports/no-unused-vars
  • unused-imports/no-unused-vars-ts

Rules that I would change:

For fun:

Two new errors for me. ๐Ÿ˜‚

"warning JSX not allowed in files with extension '.tsx'"

I'm using @strv/eslint-config-react together with @strv/eslint-config-typescript. This combination is giving me the following error:

warning  JSX not allowed in files with extension '.tsx' react/jsx-filename-extension

For Typescript we want to override this rule to allow tsx extensions but I'm not sure if we should add it directly to the typescript ruleset as its not relevant for Node.js.

Maybe we can add a @strv/eslint-config-typescript/react?

Rework stylelint-config-styled-components to a generic stylelint ruleset

The stylelint tool supports linting raw CSS and Less files. We should make use of it!

Let's rename stylelint-config-styled-components to just stylelint-config and add a generic configuration for CSS and Less, and then add a styled-components ruleset which would enable support for style-in-js patterns. ๐Ÿ‘

Possible improvements [config-base]

Hello ๐Ÿ‘‹
a couple of weeks ago (it feels like a long time now ๐Ÿ˜…) we discussed what we can do to improve STRV code quality tools. This is my first follow up about eslint-config-base.

I will share a similar update about node, react, react-native, and typescript this week.

Missing rules:
I would highly recommend taking a look at everything labeled as [major]. ๐Ÿ™‚

Missing plugins:

Missing rules from missing plugins:

  • absolute-import/no-relative-path warning [major]
  • unused-imports/no-unused-imports error [major]
  • unused-imports/no-unused-vars error [major]

Rules that can be more strict:

Rules that I would change:

  • pretty much everything can be set as error
  • if we want to be consistent then code style issues shouldn't make it to GitHub
  • I see no value in warnings. When we as a team decide which rules are important we should follow these rules. ๐Ÿ™‚
  • Personally I use warn only for rules that I know I shouldn't break but sometimes I have to (no-console, ban-ts-ignore, camelcase [because of graphql code gen], ...)

Conflict between TypeScript & React ESLint rules

So far, the recommended approach for enabling both @strv/eslint-config-react and @strv/eslint-config-typescript is that:

// .eslintrc.js
module.exports = {
  "extends": [
    "@strv/eslint-config-react",
    "@strv/eslint-config-typescript"
  ]
}

These base configurations do conflict in some aspects. I'm writing this issue while trying to properly configure code-quality-tools in a frontend project, and will add here these eventual conflicts and their solutions.

Possible improvements [config-node]

Hello ๐Ÿ‘‹
second to the last update. ๐ŸŽ‰

I will share a similar update about node, react, react-native, and typescript this week.

Missing rules:

Prefer global:

I have all set as an error but I these rules are not useful and it doesn't make much sense using them. Although it might be interesting to set them as error, never. ๐Ÿ™‚

Prefer promise:

Missing plugins:

Missing rules from missing plugins:
I have some warnings here because I was doing unconventional things in the create-opinionated-app generator. I don't do BE full time so it will be up to someone else to decide what can be disabled and what can be left as a warning.

Rules that I would change:

CLI

iOS guys are using https://fastlane.tools/ :) I think before we jump into CLI development, we should examine, what is the correct way, so it could be used universally on any platform.

Better testing for ESLint rulesets

See 47bfb8c for details about why we should probably work on improving the ruleset authoring experience. Boogs like these should not be possible to introduce into a package used by the whole company. ๐Ÿ˜ฑ ๐Ÿคฆโ€โ™‚๏ธ

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.