strvcom / code-quality-tools Goto Github PK
View Code? Open in Web Editor NEWMonorepo with some frequently-used configurations we use on projects ๐จ
License: BSD 3-Clause "New" or "Revised" License
Monorepo with some frequently-used configurations we use on projects ๐จ
License: BSD 3-Clause "New" or "Revised" License
This repo shall serve as the basis for all code quality tools used in STRV, so let's move the ESLint config in. ๐ช
babel-eslint has been deprecated. This package will no longer receive updates.
Hey, I came across to this during installation, so just FYI :]
# Yarn:
yarn add --dev @strv/stylelint-config
# npm:
npm install --save-dev @strv/stylelint-config
# Yarn:
yarn add --dev @strv/stylelint-config-styled-components
# npm:
npm install --save-dev @strv/stylelint-config-styled-components
Hi!
Firstly I would like to thank you for providing migration tutorial!
I would suggest mentioning this issue in that tutorial, specifically that this new package is not compatible with @strv/react-scripts
v3.0.0
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.
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.
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.
The old cascading config is deprecated as of ESLint 9 which was just released as alpha. We need to migrate our ESLint configuration to the new, flat eslint config format.
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.
See control-has-associated-label docs and decide whether or not we should enable this rule. ๐
The rule is part of v6.2.0 release.
A lot. See the release notes for v7.13 & v7.14.
Uhm, dunno? They do not provide a changelog for that package. ๐คทโโ ๐คฆโโ The relevant changes are since v1.5.
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
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).
The valid-jsdoc
could be enabled for TypeScript but with a different configuration, especially the requireParamType
should be disabled. Further modifications may be applied.
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.
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.
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
.
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.
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.
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
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.
code-quality-tools/packages/eslint-config-typescript/index.js
Lines 72 to 74 in 6f7d241
The rules for this package extend config-conventional from commitlint authors. It turns out that our Git guidelines state that we should Capitalize the subject line. config-conventional
, on the other hand, sets this as never.
The result is: if we follow our convention, having commitlint-config
set, we get stuck in a commit-msg
hook ๐คท.
We should consider picking either on or the other.
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
prepare-commit-msg
commitlint
package's recommended extensionWe need to use @typescript-eslint/no-unused-expressions
instead of ESlint no-unused-expressions
, because it can't handle optional chaining.
This code emits warning Expected an assignment or function call and instead saw an expression
.
fn?.('hello')
Hello ๐
last update.
Missing rules:
naming-convention
but this is one of my favorite finds ๐)Missing plugins:
Missing rules from missing plugins:
Rules that I would change:
For fun:
Two new errors for me. ๐
ESLint is deprecating its formatting rules. We need to find an alternative.
https://github.com/loeffel-io/ls-lint
Written in Go but clearly aimed at JS/front-end dev use cases. ls-lint provides a way to enforce rules for file naming and directory structures.
https://github.com/danger/danger-js
You can:
There is also this loveliness: https://github.com/danger/peril
confusing-browser-globals
looks like a great list maintained in Facebook's CRA.
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
?
Since v10 css-in-js is builtin in Stylelint
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. ๐
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:
Rules that can be more strict:
no-return-await
I saw async
keyword being misused, essentially it changes the function to promise for no reason I believe that is a bad practice)Rules that I would change:
error
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], ...)There is snyk, there is this little guy: https://github.com/lirantal/is-website-vulnerable
Should we consider adding these tools to this monorepo?
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.
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:
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.
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. ๐ฑ ๐คฆโโ๏ธ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.