-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add stylelint and prettier configurations, and create linting …
…script
- Loading branch information
Showing
7 changed files
with
231 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*# | ||
# default prettier configuration | ||
# | ||
# this file is usually referenced in your own top level .prettierrc.js. | ||
# | ||
# ``` | ||
# const settings = require('@pnpmkambrium/core/presets/default/.prettierrc.js'); | ||
# module.exports = { | ||
# ...settings, | ||
# }; | ||
# ``` | ||
# | ||
# You can remove it in case you don't use prettier | ||
#*/ | ||
module.exports = { | ||
semi: true, | ||
tabWidth: 2, | ||
singleQuote: true, | ||
printWidth: 120, | ||
trailingComma: 'all', | ||
overrides: [ | ||
/* | ||
# { | ||
# "files": ["*.json5"], | ||
# "options": { "singleQuote": false, "quoteProps": "preserve" }, | ||
# }, | ||
*/ | ||
{ files: ['*.yml'], options: { singleQuote: false } }, | ||
{ | ||
files: ['*.php'], | ||
options: { | ||
// see https://github.com/prettier/plugin-php?tab=readme-ov-file#visual-studio-code | ||
// 8.3 is currently not supported by the plugin | ||
phpVersion: '8.2', | ||
braceStyle: '1tbs', | ||
parser: 'php', | ||
}, | ||
}, | ||
], | ||
plugins: ['@prettier/plugin-php'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# | ||
# default stylelint configuration | ||
# | ||
# this file is usually referenced in your own top level .stylelintrc.yaml. | ||
# | ||
|
||
extends: | ||
- stylelint-config-recommended-scss | ||
rules: | ||
color-named: null | ||
selector-class-pattern: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import prettier from 'eslint-plugin-prettier'; | ||
import react from 'eslint-plugin-react'; | ||
import reactHooks from 'eslint-plugin-react-hooks'; | ||
import simpleImportSort from 'eslint-plugin-simple-import-sort'; | ||
import _import from 'eslint-plugin-import'; | ||
import { fixupPluginRules, includeIgnoreFile } from '@eslint/compat'; | ||
import globals from 'globals'; | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import js from '@eslint/js'; | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: js.configs.recommended, | ||
allConfig: js.configs.all, | ||
}); | ||
|
||
const gitignorePath = path.resolve(__dirname, '.gitignore'); | ||
|
||
export default [ | ||
includeIgnoreFile(gitignorePath), | ||
{ | ||
ignores: ['**/*.md', 'packages/docs/**/*.min.js', '**/*.json', '**/*.code-workspace'], | ||
}, | ||
...compat.extends('prettier'), | ||
{ | ||
plugins: { | ||
prettier, | ||
react, | ||
'react-hooks': fixupPluginRules(reactHooks), | ||
'simple-import-sort': simpleImportSort, | ||
import: fixupPluginRules(_import), | ||
}, | ||
|
||
languageOptions: { | ||
globals: { | ||
...globals['shared-node-browser'], | ||
...globals.browser, | ||
...globals.node, | ||
}, | ||
|
||
ecmaVersion: 'latest', | ||
sourceType: 'module', | ||
|
||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
|
||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
|
||
rules: { | ||
'prettier/prettier': [0], | ||
'react-hooks/rules-of-hooks': ['error'], | ||
'react-hooks/exhaustive-deps': ['warn'], | ||
'react/prop-types': ['warn'], | ||
'import/no-unresolved': ['warn'], | ||
'no-console': ['warn'], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# script is not intended to be executed directly. use `pnpm exec ...` instead or call it as package script. | ||
# | ||
# this script is used to lint the codebase | ||
# | ||
|
||
# bootstrap the environment | ||
source "$(realpath $0 | xargs dirname)/includes/bootstrap.sh" | ||
|
||
# prettier lint | ||
pnpm exec prettier --config ./.prettierrc.js --ignore-path ./.gitignore --check --ignore-unknown --log-level log . ||: | ||
|
||
# # eslint lint | ||
# # @TODO: convert config to new eslint 10 flat config | ||
pnpm exec eslint --config ./eslint.config.mjs --no-error-on-unmatched-pattern . | ||
|
||
# # stylelint lint | ||
pnpm exec stylelint --config ./.stylelintrc.yml --ignore-path ./.gitignore --allow-empty-input **/*.{css,scss} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters