airier 0.0.1
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/.babelrc +5 -0
- package/.eslintrc.js +6 -0
- package/.eslintrc.onlystyles.example.js +6 -0
- package/.husky/pre-commit +21 -0
- package/.npmrc.bak +1 -0
- package/.vscode/settings.json +26 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/index.js +7 -0
- package/modules/eslint_config.js +56 -0
- package/modules/styleguide.js +92 -0
- package/package.json +22 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
. "$(dirname -- "$0")/_/husky.sh"
|
|
3
|
+
|
|
4
|
+
echo "\n🤖 [ precommit hook ] linting before committing..."
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# If errors, make it clear they cannot commit
|
|
8
|
+
if ! lint_outcome=$( npm run lint ); then
|
|
9
|
+
echo "🚨 [ precommit hook ] lint encountered blocking issues, fix them before committing\n"
|
|
10
|
+
echo "$lint_outcome"
|
|
11
|
+
exit 1
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
# If warnings, suggest they fix them
|
|
15
|
+
if echo $lint_outcome | grep -q "warning"; then
|
|
16
|
+
echo "⚠️ [ precommit hook ] lint encountered warnings, consider fixing them before pushing\n"
|
|
17
|
+
echo "$lint_outcome"
|
|
18
|
+
exit 0
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
echo "✅ [ precommit hook ] lint encountered no blocking issues\n"
|
package/.npmrc.bak
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"i18n-ally.localesPaths": [
|
|
3
|
+
"public/locales"
|
|
4
|
+
],
|
|
5
|
+
"i18n-ally.keystyle": "nested",
|
|
6
|
+
"eslint.validate": [
|
|
7
|
+
"javascript",
|
|
8
|
+
"javascriptreact",
|
|
9
|
+
"typescript",
|
|
10
|
+
"typescriptreact"
|
|
11
|
+
],
|
|
12
|
+
"editor.codeActionsOnSave": {
|
|
13
|
+
"source.fixAll.eslint": "explicit"
|
|
14
|
+
},
|
|
15
|
+
"editor.renderWhitespace": "all",
|
|
16
|
+
"editor.formatOnSave": true,
|
|
17
|
+
"eslint.format.enable": true,
|
|
18
|
+
"eslint.run": "onType",
|
|
19
|
+
"explorer.fileNesting.enabled": true,
|
|
20
|
+
"explorer.fileNesting.patterns": {
|
|
21
|
+
"vite.config.js": "*.js,.babelrc,.nvmrc,index.html,.gitignore",
|
|
22
|
+
".env": ".env*,.*.json",
|
|
23
|
+
"firebase.json": "fire*,.fire*",
|
|
24
|
+
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Proof of Attendance Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Opinionated ESLint and VSCode style guide
|
|
2
|
+
|
|
3
|
+
A shared set of standards and preferences, enforced through eslint and vscode. Priorities: minimalism, readability, documentation.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
To use:
|
|
8
|
+
|
|
9
|
+
1. `npm install -D airier @babel/eslint-parser @babel/preset-react eslint eslint-plugin-react husky`
|
|
10
|
+
1. Copy `.eslintrc.js` to your project's `.eslintrc.js`
|
|
11
|
+
1. Copy `.babelrc` to your project's `.babelrc`
|
|
12
|
+
1. Copy `.vscode/settings.json` to your project's `.vscode/settings.json`
|
|
13
|
+
1. Copy `.husky/pre-commit` to your project's `.husky/pre-commit`
|
|
14
|
+
1. Run husky initial setup
|
|
15
|
+
|
|
16
|
+
Lazy shell
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
npm install -D airier @babel/eslint-parser @babel/preset-react eslint eslint-plugin-react husky
|
|
20
|
+
mkdir .vscode .husky
|
|
21
|
+
|
|
22
|
+
# Download files
|
|
23
|
+
curl https://raw.githubusercontent.com/actuallymentor/airier/main/.eslintrc.js --output .eslintrc.js
|
|
24
|
+
curl https://raw.githubusercontent.com/actuallymentor/airier/main/.vscode/settings.json --output .vscode/settings.json
|
|
25
|
+
curl https://raw.githubusercontent.com/actuallymentor/airier/main/.husky/pre-commit --output .husky/pre-commit
|
|
26
|
+
curl https://raw.githubusercontent.com/actuallymentor/airier/main/.babelrc --output .babelrc
|
|
27
|
+
git add -f .eslintrc.js .babelrc .vscode/* .husky/*
|
|
28
|
+
chmod ug+x .husky/*
|
|
29
|
+
npm pkg set scripts.prepare="husky install"
|
|
30
|
+
npm pkg set scripts.lint="eslint --fix src"
|
|
31
|
+
npm run prepare
|
|
32
|
+
npx husky add .husky/pre-commit
|
|
33
|
+
git add .husky/pre-commit
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Making changes
|
|
37
|
+
|
|
38
|
+
The relevant source files are in `modules/`. If you make a change, you can update the package by:
|
|
39
|
+
|
|
40
|
+
1. Making the changes
|
|
41
|
+
1. Updating the version number in `package.json`
|
|
42
|
+
1. Pushing to the main branch of the repo or opening a pull request. Changes are deployed and published through github actions. Publishing requires a version bump in `package.json`.
|
|
43
|
+
|
|
44
|
+
### Using this repo as a template
|
|
45
|
+
|
|
46
|
+
If you are cloning this repo and want to reuse it to create an npm package. These are the one-time setup instructions:
|
|
47
|
+
|
|
48
|
+
1. You need to do the one-time first publishing manually by running `npm publish --access public` in the root of the project. This will create the package on npmjs and allow you to create a granular token.
|
|
49
|
+
1. You need to obtain a NPM_ACCESS_TOKEN on npmjs (https://www.npmjs.com/settings/YOURUSERNAME/tokens/granular-access-tokens/new). Note that granular tokens expire!
|
|
50
|
+
# airier
|
package/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const styleguide = require('./styleguide.js')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
|
|
5
|
+
// Recommended features
|
|
6
|
+
"extends": [ "eslint:recommended", "plugin:react/recommended" ],
|
|
7
|
+
|
|
8
|
+
// Plugins
|
|
9
|
+
plugins: [ 'unused-imports' ],
|
|
10
|
+
|
|
11
|
+
// React settings
|
|
12
|
+
"settings": {
|
|
13
|
+
"react": { "version": "detect" }
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
// Parser features
|
|
17
|
+
parser: "@babel/eslint-parser",
|
|
18
|
+
parserOptions: {
|
|
19
|
+
requireConfigFile: false,
|
|
20
|
+
ecmaFeatures: {
|
|
21
|
+
jsx: true
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
// Rules
|
|
26
|
+
rules: {
|
|
27
|
+
|
|
28
|
+
// Import styleguide
|
|
29
|
+
...styleguide,
|
|
30
|
+
|
|
31
|
+
// React config
|
|
32
|
+
"react/no-unescaped-entities": 0,
|
|
33
|
+
"react/react-in-jsx-scope": 0, // CRA globally imports "react" so we don't need to do it
|
|
34
|
+
"react/prop-types": 0,
|
|
35
|
+
"react/display-name": 0
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
// What environment to run in
|
|
39
|
+
env: {
|
|
40
|
+
node: true,
|
|
41
|
+
browser: true,
|
|
42
|
+
mocha: true,
|
|
43
|
+
jest: false,
|
|
44
|
+
es6: true
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// What global variables should be assumed to exist
|
|
48
|
+
globals: {
|
|
49
|
+
context: true,
|
|
50
|
+
cy: true,
|
|
51
|
+
it: true,
|
|
52
|
+
Cypress: true,
|
|
53
|
+
expect: true
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Severity rationale:
|
|
2
|
+
// none: we don't care about this at all
|
|
3
|
+
// warn: we recomment this to change, but there are instances where you can choose to ignore it
|
|
4
|
+
// error: there is no reason for you to do this
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
|
|
8
|
+
/* ///////////////////////////////
|
|
9
|
+
// Built-in rules
|
|
10
|
+
// /////////////////////////////*/
|
|
11
|
+
|
|
12
|
+
// No semi colons, note that "never" does not pose ASI hazard
|
|
13
|
+
"semi": [ "error", "never", ],
|
|
14
|
+
|
|
15
|
+
// Indentation setting
|
|
16
|
+
"indent": [ "warn", 4 ],
|
|
17
|
+
|
|
18
|
+
// Allow unnamed exports
|
|
19
|
+
"import/no-anonymous-default-export": 0,
|
|
20
|
+
|
|
21
|
+
// Prefer arrow callbacks
|
|
22
|
+
"prefer-arrow-callback": "warn",
|
|
23
|
+
|
|
24
|
+
// Do not mix spaces and tabs
|
|
25
|
+
"no-mixed-spaces-and-tabs": "error",
|
|
26
|
+
|
|
27
|
+
// Require spacing between brackets and keywords
|
|
28
|
+
"object-curly-spacing": [ "error", "always" ],
|
|
29
|
+
"array-bracket-spacing": [ "error", "always" ],
|
|
30
|
+
"block-spacing": [ "error", "always" ],
|
|
31
|
+
"space-before-blocks": [ "error", "always" ],
|
|
32
|
+
"brace-style": [ "error", "1tbs" ],
|
|
33
|
+
"keyword-spacing": [ "error", {
|
|
34
|
+
overrides: {
|
|
35
|
+
if: { after: false },
|
|
36
|
+
for: { after: false },
|
|
37
|
+
while: { after: false }
|
|
38
|
+
}
|
|
39
|
+
} ],
|
|
40
|
+
"arrow-spacing": "error",
|
|
41
|
+
"space-in-parens": [ "error", "always" ],
|
|
42
|
+
"template-curly-spacing": [ "error", "always" ],
|
|
43
|
+
|
|
44
|
+
// Comments need a space between // and the content. //Not like this.
|
|
45
|
+
"spaced-comment": [ "error", "always" ],
|
|
46
|
+
|
|
47
|
+
// Warn of template literal variables in the wrong place
|
|
48
|
+
"no-template-curly-in-string": "warn",
|
|
49
|
+
|
|
50
|
+
// Define things before using them
|
|
51
|
+
"no-use-before-define": [ "error", { functions: false } ],
|
|
52
|
+
|
|
53
|
+
// Only throw Error objects and not literals (like strings)
|
|
54
|
+
"no-throw-literal": "error",
|
|
55
|
+
|
|
56
|
+
// Prefer the use of destructuring
|
|
57
|
+
"prefer-destructuring": "warn",
|
|
58
|
+
|
|
59
|
+
// Warn of unused variables, function argumebnts may have documentation value so are ignored
|
|
60
|
+
"no-unused-vars": [ "warn", { vars: 'all', args: 'none' } ],
|
|
61
|
+
|
|
62
|
+
// No use of "var"
|
|
63
|
+
"no-var": "error",
|
|
64
|
+
|
|
65
|
+
// No unneeded ()
|
|
66
|
+
"no-extra-parens": "error",
|
|
67
|
+
|
|
68
|
+
// Regex control character matching, only warn since it is used in the most complete known email regex
|
|
69
|
+
"no-control-regex": "off",
|
|
70
|
+
|
|
71
|
+
// No unsafe usage
|
|
72
|
+
"no-unsafe-finally": "error",
|
|
73
|
+
"no-unsafe-optional-chaining": "error",
|
|
74
|
+
"no-unsafe-negation": "error",
|
|
75
|
+
|
|
76
|
+
/* ///////////////////////////////
|
|
77
|
+
// React plugin rules
|
|
78
|
+
// /////////////////////////////*/
|
|
79
|
+
"react/jsx-closing-bracket-location": [ "warn", "line-aligned" ],
|
|
80
|
+
"react/jsx-curly-brace-presence": [ "error", { props: "never", children: "never" } ],
|
|
81
|
+
"react/jsx-curly-newline": [ "error", "consistent" ],
|
|
82
|
+
"react/jsx-curly-spacing": [ "error", { when: "always", "children": true } ],
|
|
83
|
+
"react/jsx-indent": "warn",
|
|
84
|
+
"react/jsx-indent-props": "warn",
|
|
85
|
+
"react/jsx-no-useless-fragment": "error",
|
|
86
|
+
|
|
87
|
+
/* ///////////////////////////////
|
|
88
|
+
// Plugins
|
|
89
|
+
// /////////////////////////////*/
|
|
90
|
+
"unused-imports/no-unused-imports": "warn",
|
|
91
|
+
|
|
92
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "airier",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Opinionated Eslint and VSCode style guide",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/actuallymentor/airier.git"
|
|
12
|
+
},
|
|
13
|
+
"author": "Mentor <mentor@palokaj.co> (http://github.com/actuallymentor)",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/actuallymentor/airier/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/actuallymentor/airier#readme",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"eslint-plugin-unused-imports": "^3.1.0"
|
|
21
|
+
}
|
|
22
|
+
}
|