Code Monkey home page Code Monkey logo

frolint's Introduction

frolint - FROntend LINT

Node CI

This is a monorepo that contains our common linting and formatting configurations for Wantedly's javascript projects.

If you are looking for the frolint executable documentation, please see here: frolint Readme

Packages

# Create above list with fish shell script
for package in (yarn -s lerna ls --loglevel silent)
    echo "- [$package](https://github.com/wantedly/frolint/tree/master/packages/$package) [![npm version](https://badge.fury.io/js/$package.svg)](https://badge.fury.io/js/$package)"
end

How to contribute

PRs are welcome, see the current issues open.

We are developing this project with Lerna.

Clone the repository and run

yarn

This will also trigger the lerna bootstraping process.

Running Tests:

# Runs all unit tests
yarn test

# Runs all unit tests with updating snapshots
yarn test:update

License

MIT

frolint's People

Contributors

bgpat avatar chloe463 avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar github-actions[bot] avatar izumin5210 avatar kalvin807 avatar kobayang avatar prsdta avatar qnighy avatar s-kawabe avatar yamadayuki 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

Watchers

 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

frolint's Issues

Separate ESLint and Prettier configurations

Why

Currently, the frolint command is set up to run Prettier integrated with ESLint.

What this means is that you can use the eslint-plugin-prettier plugin to run formater as if it were acting as a linter.
This has the following concerns and ideas, which we believe should be quit in this day and age. ๐Ÿค”

Idea

  • When eslint-plugin-prettier was recommended, many of the editors did not support Prettier, and the idea was that you had no choice but to use them via ESLint. However, many modern editors support Prettier execution, so this concern is almost no longer a concern.

Concerns

  • Running Prettier on ESLint slows it down.
  • In order to run Prettier on ESLint, you need to put a layer between them, which may lead to unintended behavior.
  • linter and formatter are not separated, leading to unintentional warnings in the format context as a linter warning.

The Prettier formula also recommends that in the modern era it be run alone, not on ESLint.
https://prettier.io/docs/en/integrating-with-linters.html#notes

First, we have plugins that let you run Prettier as if it was a linter rule:

  • eslint-plugin-prettier
  • stylelint-prettier
    These plugins were especially useful when Prettier was new. By running Prettier inside your linters, you didnโ€™t have to set up any > new infrastructure and you could re-use your editor integrations for the linters. But these days you can run prettier --check .
    and most editors have Prettier support.

What

Remove eslint-plugin-prettier so that Prettier runs by itself.

(This change is not disruptive to the developer experience for frolint users.)

@graphql-eslint/eslint-plugin does not work with frolint cli

Why

In the following .eslintrc, use yarn eslint . /src will work, but yarn frolint -branch master -bail will raise an error.

.eslintrc
{
  "overrides": [
    {
      "files": [
        "*.tsx",
        "*.ts"
      ],
      "extends": "wantedly-typescript",
      "parserOptions": {
        "project": [
          "./tsconfig.json",
          "./tsconfig.eslint.json"
        ]
      }
    },
    {
      "files": [
        "*.tsx",
        "*.ts"
      ],
      "processor": "@graphql-eslint/graphql"
    },
    {
      "files": [
        "./src/profile/components/profile/Sidebar/RelatedUsers/**/*.graphql"
      ],
      "parser": "@graphql-eslint/eslint-plugin",
      "parserOptions": {
        "schema": "./graphql-gateway-schema.json"
      },
      "plugins": [
        "@graphql-eslint"
      ],
      "rules": {
        "@graphql-eslint/fields-on-correct-type": [
          "error"
        ]
      }
    }
  ]
}
Internal Error: Error while loading rule '@typescript-eslint/no-floating-promises': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /path/to/project/src/path/to/Component.tsx/0_document.graphql

What

Frolint does not use `.prettierignore`

Why

When looking at the docs: https://prettier.io/docs/en/api.html#prettiergetfileinfofilepath--options

Setting options.ignorePath (string) and options.withNodeModules (boolean) influence the value of ignored (false by default).

The ignored will always be false if we don't give a proper ignorePath value.
But during a frolint run, the ignorePath is empty.

e.g. see debug log

  frolint:prettier Prettier config: { prettierConfig: {} } +9ms
# โ†‘ no `ignorePath` even though we have a .prettierignore
prettier.getFileInfo.sync(file, { ignorePath: prettierConfig.ignorePath });
// => { ignored: false, inferredParser: 'babel' } 

What

Find a way to load the .prettierignore file for the project, and convert it to a string for use as ignorePath.

Conflicting rules between eslint and prettier

Why & What

I think the following rules are conflicting between eslint and prettier.

  • space-before-function-paren
    • eslint says space is required, prettier says 'no' on the other hand.
  • comma-dangle
    • eslint says trailing comma is required, prettier says 'no'

๐Ÿ˜•

I found only two conflict rules so far, but maybe some more...? (I will report if I find some)

Add no-floating-promises as default rule

WHY & WHAT

We can now use the no-floating-promises
typescript-eslint/typescript-eslint#495

This rule forbids usage of Promise-like values in statements without handling their errors appropriately. Unhandled promises can cause several issues, such as improperly sequenced operations, ignored Promise rejections and more. Valid ways of handling a Promise-valued statement include awaiting, returning, and either calling .then() with two arguments or .catch() with one argument

How do you think about this?
@KentoMoriwaki @chloe463 @kobayang

Add wantedly_dev to NPM collaborators to eslint-plugin-wantedly

Why

Failed to publish eslint-plugin-wantedly package with permission denined.

lerna http fetch PUT 403 https://registry.npmjs.org/eslint-plugin-wantedly 621ms
lerna ERR! E403 You do not have permission to publish "eslint-plugin-wantedly". Are you logged in as the correct user?
error Command failed with exit code 1.

What

@yamadayuki Please add @wantedly_dev to NPM collaborators in eslint-plugin-wantedly to maintain the package.

Screen_Shot_2021-05-19_at_15_36_30

FYI: Other frolint packages include @wantedly_dev to NPM collaborators.

Screen_Shot_2021-05-19_at_15_37_25

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.