Git Product home page Git Product logo

eslint-plugin-actool's People

Contributors

azinit avatar lyf2000 avatar ural-2001 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

eslint-plugin-actool's Issues

Add util for testing files at rules' tests

Problem
Plugin should work with files commit's history
Besides utils for work with git, we should have access to test files, not only strings

Solution
Util for testing files, not only strings

Additional context
image

Fix maxTags param for "max-tags-file" rule

Version
0.0.0.

Expected behavior

  • Max tags will be limited to my value (2)
  • Param should be passed as object

Actual behavior

  • Max tags stop be limited and validated at all
  • Param passed as array item

Repro steps
"actool/max-tags-file": [2, {CUSTOM_VALUE}],

Additional context
image

Add some rule for temp solutions tracking

There is a problem to track temp solutions in project

Fail

Reached limit (or other criteria) of allowed temp solutions - refactor/resolve for continue!

Pass

Amount (or other criteria) of temp solutions - in allowed range

Add utils

Common description of task

  • Analyze and specify needed utils after discussing

    Look at rules

While:

  • Work with git
  • Work with comments-analyze
  • All project analyzing (for tags counting)

Add helper for validating commits diff

Used by rules

  • relevant-comments-block
  • relevant-comments-line
  • relevant-comments-module

Purpose

Add functions for validating two commits/date by available diff

function validateDiff(commit1: Commit, commit2: Commit, diff: number): boolean
function validateDiff(date1: Date, date2: Date, diff: number): boolean

image

More details about logic

WARNING

Not need to parse commits manually - only need to impl two overloads of function

image

Commits log example

b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  1) import React from "react";
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300  2) import { Button } from "antd";
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  3) import { useAuth } from "../hooks";
a90ad368 (Ilya Azin 2020-11-21 23:38:33 +0300  4) import { routes } from "../consts";
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  5)
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  6) const User = () => {
aad365d1 (Ilya Azin 2020-11-21 18:35:36 +0300  7)     const { isAuth, logout, viewer } = useAuth();
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  8)
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  9)     /**
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 10)      * FIXME: Использовать Link?
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 11)      * (но для этого нужна будет обертка Auth.Router на уровне App)
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 12)      */
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 13)     return (
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 14)         <span className="auth-user">
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 15)             {isAuth && (
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 16)                 <>
44054cbb (Ilya Azin 2020-11-12 12:47:18 +0300 17)                     {/* FIXME: use h3 instead */}
deb15768 (Ilya Azin 2020-11-21 23:21:15 +0300 18)                     <a className="m-4 text-white" href={`/${viewer?.username}`}>
deb15768 (Ilya Azin 2020-11-21 23:21:15 +0300 19)                         {viewer?.username}
16799632 (Ilya Azin 2020-11-02 10:28:39 +0300 20)                     </a>
a90ad368 (Ilya Azin 2020-11-21 23:38:33 +0300 21)                     <Button className="m-4" href={routes.logout} onClick={logout}>
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 22)                         Logout
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 23)                     </Button>
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 24)                 </>
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 25)             )}
824d8e96 (Ilya Azin 2020-11-21 18:56:25 +0300 26)             {!isAuth && (
a90ad368 (Ilya Azin 2020-11-21 23:38:33 +0300 27)                 <Button className="m-4" href={routes.login}>
824d8e96 (Ilya Azin 2020-11-21 18:56:25 +0300 28)                     Sign In
824d8e96 (Ilya Azin 2020-11-21 18:56:25 +0300 29)                 </Button>
824d8e96 (Ilya Azin 2020-11-21 18:56:25 +0300 30)             )}
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 31)         </span>
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 32)     );
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 33) };
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 34)
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 35) export default User;

Добавить документацию по правилам

Задача

  • Реализовать общую документацию для всех правил по всем имеющимся (ниже) источникам
  • Для каждого правила будет документация в отдельном {rule}.md файле (пример)
  • ВАЖНО: Я тут пересмотрел - скорее всего лучше действительно оставить 3 правила:
    • max-tags (с доп.параметром scope: ["file", "project"])
    • relevant-comments (с доп. параметром scope: ["line", "block", "module"])
    • no-commented-code
    • Остальные параметры для правил оставляем само собой - как указано расписанной доке (ссылка ниже). На кастомизации такое упрощение не сильно должно сказаться - зато удобнее пользоваться

Ресурсы

Написать утилиту, которая по указанным строкам находит последний коммит

INPUT

type Commit = {
  hash: string;
  date: string; (or Date - как удобнее) 
  name: string;
}

// Все это будет приходить извне

OUTPUT

type Args = {
    lines: [number, number];
    filepath: string;
}
function getLastCommitOf({ lines, filepath }): Commit

getLastCommitOf({
   lines: [1, 5],
   filepath: "lib/rules/some-rule.js"
})
// { hash: "d32hea7f", name: "Ilya Azin", date: "2020-11-20T123" }

TIP

В утилитах уже есть метод getCommitByLine, лучше воспользоваться им внутри реализации getLastCommitOf

image

Add tasks templates

  • Look at other open source examples
  • Should contain (at least):
    • Rule proposal
    • Bug
    • Assignment

Add recommended config

Problem
There is not a recommended config for plugin

Solution
Add recommended config for plugin (autogenerated or manually created)

Additional context
image

Refactor max-tags-file

Problem
Current impl is very hardcoded and not reliable

Solution

  • More correct and strict max-tags-file rule impl
  • Add max-tags-proj scope

Add commits history parser for each line of code in file

Used by rules

  • relevant-comments-block
  • relevant-comments-line
  • relevant-comments-module
  • no-commented-code

Purpose

Parser (function):

  • should can get commit by line
  • should has access to git history of file by path

API

getCommitByLine(filePath, 1)
// { author: "Ilya Azin", date: "2020-11-02 09:51:49+0300", commit: "b6988094" }

getCommitByLine(filePath, 24)
// { author: "Ilya Azin", date: "2020-11-02 10:05:41+0300", commit: "a0e08b6b" }

File example

Should be parse by file, not by string

Aproximate !!!

b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  1) import React from "react";
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300  2) import { Button } from "antd";
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  3) import { useAuth } from "../hooks";
a90ad368 (Ilya Azin 2020-11-21 23:38:33 +0300  4) import { routes } from "../consts";
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  5)
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  6) const User = () => {
aad365d1 (Ilya Azin 2020-11-21 18:35:36 +0300  7)     const { isAuth, logout, viewer } = useAuth();
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  8)
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300  9)     /**
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 10)      * FIXME: Использовать Link?
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 11)      * (но для этого нужна будет обертка Auth.Router на уровне App)
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 12)      */
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 13)     return (
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 14)         <span className="auth-user">
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 15)             {isAuth && (
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 16)                 <>
44054cbb (Ilya Azin 2020-11-12 12:47:18 +0300 17)                     {/* FIXME: use h3 instead */}
deb15768 (Ilya Azin 2020-11-21 23:21:15 +0300 18)                     <a className="m-4 text-white" href={`/${viewer?.username}`}>
deb15768 (Ilya Azin 2020-11-21 23:21:15 +0300 19)                         {viewer?.username}
16799632 (Ilya Azin 2020-11-02 10:28:39 +0300 20)                     </a>
a90ad368 (Ilya Azin 2020-11-21 23:38:33 +0300 21)                     <Button className="m-4" href={routes.logout} onClick={logout}>
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 22)                         Logout
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 23)                     </Button>
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 24)                 </>
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 25)             )}
824d8e96 (Ilya Azin 2020-11-21 18:56:25 +0300 26)             {!isAuth && (
a90ad368 (Ilya Azin 2020-11-21 23:38:33 +0300 27)                 <Button className="m-4" href={routes.login}>
824d8e96 (Ilya Azin 2020-11-21 18:56:25 +0300 28)                     Sign In
824d8e96 (Ilya Azin 2020-11-21 18:56:25 +0300 29)                 </Button>
824d8e96 (Ilya Azin 2020-11-21 18:56:25 +0300 30)             )}
a0e08b6b (Ilya Azin 2020-11-02 10:05:41 +0300 31)         </span>
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 32)     );
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 33) };
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 34)
b6988094 (Ilya Azin 2020-11-02 09:51:49 +0300 35) export default User;

v.0.0.X

Problem
There is not enough functinoality of plugin

Solution
Add and specify base functionality of MVP version of plugin

  • impl base rules:
    • max-tags
    • relevant-comments
    • no-commented-code
  • impl base options

Add base impl for code block iterating

Нужно разобраться как итерироваться по блокам кода а не по комментариям

Или же - нужно научиться находить по имеющимся комментарий относящийся к ним блок кода

Сейчас же пока это захардкожено (нужно находить не просто строчку, а весь интервал, для комментариев модульных - должно быть понимание, что сранивается весь файл)

Т.е. условно должна быть логика, которая на основании комментария дает нам строки соответствующего кода, который мы должны сравнить по коммитам

image

image

Add CI

Add CI logic

  • Github Actions Workflow
  • Testing by ESLint
  • Merge with 1 approve at least
  • dev/master branches

Add CD

  • Publish on npm when merged into master?

Add max-tags-file rule

For preventing TODOs/FIXMEs chaos

Fail

// TODO: 1
// FIXME: 2
...
// TODO: 8 (|| { USER_CONFIGURED by params })

Pass

// TODO: 1
// FIXME: 2
...
// TODO: 7 (|| { USER_CONFIGURED - 1 by params })

Добавить утилиту для рассчета расстояния между коммитами

Нужна утилита, которая получает разницу между коммитами, скорее всего с вытягиванием истории

type Commit = {
     author: string;
     hash: string;
     date: string;
};

// Данные приходят извне, нужно реализовать саму функцию
function getCommitsDiff(commit1: Commit, commit2: Commit): Commit[]

getCommitsDiff(c1, c2) // Commit [4] (т.е. между коммитами присутствует еще 4 промежуточных)

Улучшить обработку файлов в jsx

Problem
Долго обрабатываются на данный момент jsx файлы

Solution
Оптимизировать

Additional context
Обычные файлы - пролетают быстро, а tsx же - тормозит

image

Разобраться с кастомизацией параметров для правил

Problem

Не работает кастомизация параметров даже для реализованных правил (см. max-tags)

Solution

  • Разобраться с тем как работает кастомизация правил
  • Для примера - реализовать базовую кастомизацию параметра max для правила max-tags согласно доке

    Т.е. чтобы можно было задать с помощью объекта макс. кол-во тегов на файл

  • Если надо - переделать документацию (null vs { disabled: true })

Additional

Сейчас же это не работает
image

Написать утилиту, которая фильтрует коммиты относительно текущего кода

Т.е. должна делать примерно следующее:

type Commit = {
    hash: string;
    name: string;
    date: string; // или Date - что удобнее будет
}

type Args = {
   commits: Commit[];
    // Как мне кажется, так удобнее будет обозначить рамки исходного кода который будет служить фильтром - но на свое усмотрение, может получше что найдется
    lines: string[];
    filepath: string;
}

// Все извне нам будет приходить, а вот реализовать надо будет саму функцию
function filterCommitsBySrc({ commits, lines, filepath }: Args}): Commit[]

filterCommitsBySrc({
   commits: myCommits // Commit[]
   lines: codeBlock.getLines() // string[]
   filepath: "/lib/rules/some-rule.js" // string
})

// Commit[] (filtered by specified lines and filepath)

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.