Skip to content

Commit

Permalink
chore: 🤖 add linters and fix misleading docs
Browse files Browse the repository at this point in the history
add linters and fix misleading docs
  • Loading branch information
tal authored and tal committed Nov 9, 2023
1 parent ebeffc8 commit 4cfdc61
Show file tree
Hide file tree
Showing 19 changed files with 1,460 additions and 541 deletions.
13 changes: 0 additions & 13 deletions .depcheckrc.json

This file was deleted.

45 changes: 30 additions & 15 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ permissions:
contents: read

jobs:
depcheck:
name: Depcheck

runs-on: ubuntu-latest
steps:
- name: Setup Node environment
uses: Exlint/[email protected]
with:
node-version: 18.18.2
package-manager: pnpm
package-manager-version: 8.10.0

- name: Test Depcheck
run: pnpm depcheck

inflint:
name: Inflint

Expand Down Expand Up @@ -86,6 +71,36 @@ jobs:
- name: Test ESLint
run: pnpm lint

knip:
name: Knip
runs-on: ubuntu-latest

steps:
- name: Setup Node environment
uses: Exlint/[email protected]
with:
node-version: 20.9.0
package-manager: pnpm
package-manager-version: 8.10.2

- name: Knip
run: pnpm knip

cspell:
name: CSpell
runs-on: ubuntu-latest

steps:
- name: Setup Node environment
uses: Exlint/[email protected]
with:
node-version: 20.9.0
package-manager: pnpm
package-manager-version: 8.10.2

- name: CSpell
run: pnpm cspell

build:
name: Build

Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm depcheck && pnpm exec lint-staged
pnpm knip && pnpm exec lint-staged
9 changes: 0 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,5 @@
},
"[ignore]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"material-icon-theme.files.associations": {
".inflintignore": "crystal",
"inflint.config.cjs": "crystal",
"czvinyl.config.cjs": "ocaml",
".depcheckrc.json": "parcel",
".cz.json": "jinja",
"tsconfig.paths.json": "tsconfig",
"release.config.cjs": "semantic-release"
}
}
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,43 +64,44 @@ Configuration can be set in the following files:
Currently, a TypeScript configuration file is not supported: https://github.com/Codex-/cosmiconfig-typescript-loader/issues/60

### Rules format
When applying rules either via the CLI or other conifguration, you must follow the rules format.
`1` and `warn` are warnings rules, `2` and `error` are errors rules.
Each rule has key and value. The key represents the glob pattern. When a file matches the pattern, it will be enfocred by the rule.
They rule value represents the rule enforcement.
Rules enforcement format:
When applying rules either via the CLI or other configuration, you must follow the rules format.
"`1`" and "`warn`" are warnings rules, "`2`" and "`error`" are errors rules.
Each rule has key and value. The key represents the glob pattern. When a file matches the pattern, it will be enforced by the rule.
The rule value represents the rule enforcement.

**Rules enforcement format:**
- Set rules of files-existence: `1 | 2 | 'warn' | 'error' | [1] | [2] | ['warn'] | ['error']`

**Example**: `{ 'src/**/*': 2 }` → Inflint will emit error if there are any files/folders inside `src` folder
**Example**: `{ './src/**/*': 2 }` → Inflint emits an error if there are any files/folders inside "src" folder
- Set rules to match file names conventions: `[1, <convention>] | [2, <convention>] | ['warn', <convention>]| ['error', <convention>]`

**Example**: `{ 'src/**/*': [1, 'kebab-case'] }` &rarr; Inflint will emit error if there are any files/folder with "kebab-case" convention name inside `src` folder
**Example**: `{ './src/**/*': [1, 'kebab-case'] }` &rarr; Inflint emits an error if there are any files/folder which do not match the "kebab-case" convention name inside "src" folder.
- Set rules options: `[1, <convention>(optional), <options>] | [2, <convention>(optional), <options>] | ['warn', <convention>(optional), <options>] | ['error', <convention>(optional), <options>]`

**Example1**: `{ 'src/**/*': [1, { onlyFiles: true }] }` &rarr; Inflint will emit error if there are any files inside `src` folder (and ignores folders if there are)
**Example1**: `{ './src/**/*': [1, { onlyFiles: true }] }` &rarr; Inflint emits an error if there are any files inside "src" folder (and allows folders to exist)

**Example2**: `{ 'src/**/*': [1, 'point.case', { onlyFiles: true }] }` &rarr; Inflint will emit error if there are any files with "point-case" convention name inside `src` folder (and ignores folders if there are)
**Example2**: `{ './src/**/*': [1, 'point.case', { onlyFiles: true }] }` &rarr; Inflint emits an error if there are any files which do not match the "point-case" convention name inside "src" folder (and allows folders inside "src" folder not to match the "point.case" pattern)


> If you provide unknown convention which isn't a readymade one or a configured alias, Inflint will consider the "convention" as regex.
> If you provide unknown convention which isn't known one or a configured alias, Inflint considers the "convention" as regex.
### Rule option
You can set options for any rule, in order to get some customization.
- `onlyDirectories`: Boolean (default: `false`)

Inflint will check the rule with directories only. Will skip files.
Inflint checks the rule with directories only, skips files.

- `onlyFiles`: Boolean (default: `false`)

Inflint will check the rule with files only. Will skip directories.
Inflint checks the rule with files only, skips directories.

- `dot`: Boolean (default: `true`)

Allow Inflint to match files and directories that begin with a period (.)
Allow Inflint to match files and directories starting with a period (`.`).

- `caseSensitiveMatch`: Boolean (default: `true`)

Enables a case-sensitive mode for matching files.
Enables a case-sensitive mode for matching files and folders.

### File names conventions
You can set file names conventions rules using known ones. Inflint allows you to set the following:
Expand All @@ -126,15 +127,15 @@ The JSON should follow the rules format described above.
**Example**: `inflint --rule "{ \"src/**/*\": [1] }"`

### Aliases
You can use the readymade conventions, or you can add your own by applying aliases, via the CLI or other configuration.
To use the aliases, simply use the alias name as you would use readymade convention.
You can use the known conventions, or you can add your own by applying aliases, via the CLI or other configuration.
To use the aliases, simply use the alias name as you would use a known convention.
Aliases should be applied with the following format:
- `<alias_name>: <regex>` Inflint will apply the alias name to match the provided regex.

**Example**: Applying the alias `{ myAlias: '^.*$' }` and the rule `{ 'src/**/*': [2, 'myAlias'] }` &rarr; Inflint will match any file/folder in `src` directory and validates the provided regex matches it.
- `<alias_name>: [<regex>, <regex_flags>]` Inflint will apply the alias name to match the provided regex with given flags.
**Example**: Applying the alias `{ myAlias: '^.*$' }` and the rule `{ 'src/**/*': [2, 'myAlias'] }` &rarr; Inflint checks any file/folder in "src" folder to match the alias regex.
- `<alias_name>: [<regex>, <regex_flags>]` Inflint applies the alias name to match the provided regex with given regex flags.

**Example**: `{ myAlias: ['^.*$', 'i'] }` &rarr; Any rule applied with `myAlias` alias will try to match file names by the provided regex and the `i` regex flag.
**Example**: `{ myAlias: ['^.*$', 'i'] }` &rarr; Any rule applied with `myAlias` alias tries to match files/folders names by the provided regex and the `i` regex flag.

### CLI Aliases
When adding aliases via the CLI, you need to provide a valid JSON for the `--alias` argument. You can provide multiple aliases.
Expand Down
24 changes: 24 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"language": "en",
"ignorePaths": ["./pnpm-lock.yaml", "./renovate.json", "./CHANGELOG.md"],
"words": [
"inflintrc",
"ICLI",
"inflint",
"inflintignore",
"nocase",
"exlint",
"rofe",
"kebabcase",
"pointcase",
"screamingsnakecase",
"snakecase",
"pascalcase",
"camelcase",
"knip",
"czvinyl",
"setdev",
"esbenp",
"foxundermoon"
]
}
15 changes: 15 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://unpkg.com/knip@2/schema.json",
"entry": "./src/index.ts",
"project": ["./src/**/*"],
"webpack": false,
"ignoreDependencies": [
"@types/webpack-node-externals",
"commitizen",
"rimraf",
"ts-loader",
"tsconfig-paths-webpack-plugin",
"webpack-node-externals",
"webpack-shell-plugin-next"
]
}
4 changes: 2 additions & 2 deletions lint-staged.config.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
'./**/*.ts': ['eslint --fix -c ./.eslintrc.cjs', () => 'tsc --noEmit'],
'./**/*.{ts,js,json}': 'prettier --write -c ./.prettierrc.cjs',
'./**/*': 'inflint -c ./inflint.config.cjs',
'./**/*.{ts,js,json,yaml}': 'prettier --write -c ./.prettierrc.cjs',
'./**/*': ['inflint -c ./inflint.config.cjs', 'cspell lint -c ./cspell.json --no-progress --no-summary'],
};

module.exports = config;
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@
"lint": "eslint -c ./.eslintrc.cjs \"**/*.{ts,js,cjs}\"",
"prettier": "prettier --check **/*.{ts,js,cjs,json,yaml}",
"type-check": "tsc -p ./tsconfig.json",
"depcheck": "depcheck --config ./.depcheckrc.json",
"inflint": "inflint -c ./inflint.config.cjs"
"inflint": "inflint -c ./inflint.config.cjs",
"knip": "knip -c ./knip.json -t ./tsconfig.json",
"cspell": "cspell lint -c ./cspell.json --gitignore --no-progress --no-summary **"
},
"dependencies": {
"@expo/spawn-async": "1.7.2",
Expand All @@ -77,9 +78,9 @@
"@types/webpack-node-externals": "3.0.3",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"cz-vinyl": "2.3.0",
"commitizen": "4.3.0",
"depcheck": "1.4.7",
"cspell": "8.0.0",
"cz-vinyl": "2.3.0",
"eslint": "8.52.0",
"eslint-config-prettier": "8.10.0",
"eslint-plugin-deprecation": "1.5.0",
Expand All @@ -90,6 +91,7 @@
"figlet": "1.7.0",
"husky": "8.0.3",
"is-ci": "3.0.1",
"knip": "2.40.0",
"lint-staged": "13.3.0",
"npm-run-all": "4.1.5",
"prettier": "2.8.8",
Expand Down
Loading

0 comments on commit 4cfdc61

Please sign in to comment.