@averay/codeformat 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.prettierrc.json CHANGED
@@ -1,5 +1,7 @@
1
1
  {
2
- "$schema": "http://json.schemastore.org/prettierrc",
2
+ "$schema": "https://json.schemastore.org/prettierrc",
3
+ "arrowParens": "always",
4
+ "proseWrap": "never",
3
5
  "semi": true,
4
6
  "singleQuote": true,
5
7
  "trailingComma": "all"
package/README.md CHANGED
@@ -12,16 +12,36 @@ A very opinionated collection of configurations for a number of code formatting
12
12
  ln -s node_modules/@averay/codeformat/.editorconfig node_modules/@averay/codeformat/.prettierrc.json ./
13
13
  ```
14
14
 
15
- 3. Generate the ESLint configuration after any custom ignore definitions:
16
-
17
- ```js
18
- // eslint.config.js
19
- import { makeEslintConfig } from '@averay/codeformat';
20
-
21
- export default [
22
- {
23
- ignores: ['dist/**/*'],
24
- },
25
- ...makeEslintConfig({ tsconfigPath: './tsconfig.json' }),
26
- ];
27
- ```
15
+ 3. Import and call the relevant configuration builders for specific tools
16
+
17
+ 4. Lint the codebase with `npx codeformat check`, or apply automatic fixes with `npx codeformat fix`
18
+
19
+ ### ESLint
20
+
21
+ Create an `eslint.config.js` file and create the configuration:
22
+
23
+ ```js
24
+ // eslint.config.js
25
+ import { makeEslintConfig } from '@averay/codeformat';
26
+
27
+ export default [
28
+ {
29
+ ignores: ['dist/**/*'],
30
+ },
31
+ ...makeEslintConfig({ tsconfigPath: './tsconfig.json' }),
32
+ // Custom overrides can be added here
33
+ ];
34
+ ```
35
+
36
+ ### Stylelint
37
+
38
+ Create a `stylelint.config.cjs` file and create the configuration:
39
+
40
+ ```js
41
+ // stylelint.config.cjs
42
+ const { makeStylelintConfig } = require('@averay/codeformat');
43
+
44
+ module.exports = makeStylelintConfig();
45
+ ```
46
+
47
+ _(Stylelint does not currently support ESM so a `.cjs` file with CommonJS import & export syntax must be used)_
@@ -0,0 +1,31 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ # Parse arguments
6
+ ACTION="$1"
7
+ DIR="$2"
8
+ if [ "$DIR" = '' ]; then
9
+ DIR='.'
10
+ fi
11
+
12
+ CONFIG_PATH_TYPESCRIPT="$DIR/tsconfig.json"
13
+
14
+ if [ "$ACTION" = 'check' ]; then
15
+ npx eslint "$DIR"
16
+ npx prettier --check "$DIR"
17
+ if [ -f "$CONFIG_PATH_TYPESCRIPT" ]; then
18
+ npx tsc --noEmit "$DIR/tsconfig.json"
19
+ fi
20
+ npx stylelint --allow-empty-input "$DIR/**/*.{css,sass,scss}"
21
+ elif [ "$ACTION" = 'fix' ]; then
22
+ npx eslint --fix "$DIR"
23
+ npx prettier --write "$DIR"
24
+ npx stylelint --fix --allow-empty-input "$DIR/**/*.{css,sass,scss}"
25
+ else
26
+ # Invalid/unset arguments
27
+ echo "Usage:
28
+ $0 check [root-path]
29
+ $0 fix [root-path]" >&2
30
+ exit 1
31
+ fi