@atomicsmash/coding-standards 1.0.0

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/.eslintrc.cjs ADDED
@@ -0,0 +1,5 @@
1
+ const eslintConfig = require("@atomicsmash/coding-standards").eslintConfig;
2
+ module.exports = {
3
+ ...eslintConfig,
4
+ ignorePatterns: [...(eslintConfig.ignorePatterns ?? []), "**/*.d.ts"],
5
+ };
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @atomicsmash/coding-standards
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`cf2e7f5`](https://github.com/AtomicSmash/packages/commit/cf2e7f590af7aa404a053e7490743b5cb0af3401) - First release of coding standards
@@ -0,0 +1 @@
1
+ module.exports = ["defaults and >1% and not samsung > 0 and not op_mini all"];
@@ -0,0 +1 @@
1
+ module.exports = { extends: ["@commitlint/config-conventional"] };
@@ -0,0 +1,79 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ /**
5
+ * Search for `package.json`
6
+ * @param {string} from - search `from` directory.
7
+ * @returns {string|void} - path to package.json
8
+ */
9
+ function findNearestPackageJson(from) {
10
+ from = path.resolve(from);
11
+ const parent = path.dirname(from);
12
+ if (!from || parent === from) {
13
+ return;
14
+ }
15
+
16
+ const pkg = path.join(from, "package.json");
17
+ if (fs.existsSync(pkg)) {
18
+ return pkg;
19
+ }
20
+ return findNearestPackageJson(parent);
21
+ }
22
+
23
+ /**
24
+ * Load the nearest package.json
25
+ * @param {string} cwd
26
+ * @returns
27
+ */
28
+ function loadPackage(cwd) {
29
+ const pkgFile = findNearestPackageJson(cwd);
30
+ if (!pkgFile) return;
31
+ return JSON.parse(fs.readFileSync(pkgFile, "utf-8"));
32
+ }
33
+
34
+ function determinePackageNamesAndMethods(cwd = process.cwd()) {
35
+ const packageImport = loadPackage(cwd) || {};
36
+ const packageNames = Object.keys(packageImport.dependencies || {}).concat(
37
+ Object.keys(packageImport.devDependencies || {}),
38
+ );
39
+ return { packageNames };
40
+ }
41
+
42
+ /** @type { import("@cspell/cspell-types").CSpellUserSettings } */
43
+ const config = {
44
+ language: "en-GB",
45
+ words: [
46
+ ...determinePackageNamesAndMethods().packageNames,
47
+ "atomicsmash",
48
+ "commitlint",
49
+ "tsbuildinfo",
50
+ "sass",
51
+ ],
52
+ languageSettings: [
53
+ {
54
+ languageId: "*",
55
+ locale: "en-GB",
56
+ },
57
+ {
58
+ languageId: "css, less, scss, sass",
59
+ locale: "en-US",
60
+ dictionaries: ["css"],
61
+ },
62
+ {
63
+ languageId: "javascript,typescript,javascriptreact,typescriptreact",
64
+ locale: "en-GB",
65
+ dictionaries: ["typescript"],
66
+ },
67
+ {
68
+ languageId: "php",
69
+ locale: "en-GB",
70
+ dictionaries: ["php", "html"],
71
+ },
72
+ {
73
+ languageId: "html,vue-html,javascriptreact,typescriptreact",
74
+ locale: "en-GB",
75
+ dictionaries: ["html"],
76
+ },
77
+ ],
78
+ };
79
+ module.exports = config;
@@ -0,0 +1,64 @@
1
+ module.exports = {
2
+ ignorePatterns: [".eslintrc.cjs", "dist/**/*", "**/*.config.*"],
3
+ plugins: ["import"],
4
+ extends: ["eslint:recommended", "prettier"],
5
+ env: {
6
+ browser: true,
7
+ commonjs: true,
8
+ node: true,
9
+ es2017: true,
10
+ },
11
+ rules: {
12
+ "no-case-declarations": ["off"],
13
+ "import/order": [
14
+ "error",
15
+ {
16
+ alphabetize: {
17
+ order: "asc",
18
+ },
19
+ groups: [
20
+ "type",
21
+ "builtin",
22
+ "external",
23
+ "internal",
24
+ "parent",
25
+ ["sibling", "index"],
26
+ ],
27
+ "newlines-between": "ignore",
28
+ pathGroups: [],
29
+ pathGroupsExcludedImportTypes: [],
30
+ },
31
+ ],
32
+ "prefer-const": ["error"],
33
+ "no-var": ["error"],
34
+ "import/no-duplicates": "warn",
35
+ },
36
+ overrides: [
37
+ {
38
+ files: ["*.ts", "*.tsx", "*.mts", "*.cts"],
39
+ parser: "@typescript-eslint/parser",
40
+ plugins: ["@typescript-eslint", "import"],
41
+ extends: [
42
+ "eslint:recommended",
43
+ "plugin:@typescript-eslint/recommended",
44
+ "plugin:@typescript-eslint/recommended-requiring-type-checking",
45
+ "plugin:import/typescript",
46
+ "prettier",
47
+ ],
48
+ rules: {
49
+ "@typescript-eslint/naming-convention": [
50
+ "error",
51
+ { selector: "variableLike", format: ["camelCase"] },
52
+ { selector: "function", format: ["camelCase", "PascalCase"] },
53
+ { selector: "typeLike", format: ["PascalCase"] },
54
+ {
55
+ selector: "variable",
56
+ types: ["boolean"],
57
+ format: ["PascalCase"],
58
+ prefix: ["is", "should", "has", "can", "did", "will"],
59
+ },
60
+ ],
61
+ },
62
+ },
63
+ ],
64
+ };
package/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export const browserslistConfig: import("browserslist").Config;
2
+ export const commitlintConfig: import("@commitlint/types").UserConfig;
3
+ export const cspellConfig: import("@cspell/cspell-types").CSpellUserSettings;
4
+ export const eslintConfig: import("eslint").Linter.Config;
5
+ export const prettierConfig: import("prettier").Config;
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ browserslistConfig: require("./browserslist"),
3
+ commitlintConfig: require("./commitlint"),
4
+ cspellConfig: require("./cspell"),
5
+ eslintConfig: require("./eslint"),
6
+ prettierConfig: require("./prettier"),
7
+ };
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@atomicsmash/coding-standards",
3
+ "version": "1.0.0",
4
+ "description": "A collection of coding standards configurations.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "dependencies": {
8
+ "eslint": "^8.20.0",
9
+ "@commitlint/cli": "^17.0.3",
10
+ "@commitlint/config-conventional": "^17.0.3",
11
+ "prettier": "^2.7.1",
12
+ "@typescript-eslint/eslint-plugin": "^5.31.0",
13
+ "@typescript-eslint/parser": "^5.31.0",
14
+ "eslint-config-prettier": "^8.5.0",
15
+ "eslint-import-resolver-typescript": "^3.3.0",
16
+ "eslint-plugin-import": "^2.26.0"
17
+ },
18
+ "devDependencies": {
19
+ "browserslist": "^4.21.5",
20
+ "@cspell/cspell-types": "^6.18.1"
21
+ },
22
+ "bundledDependencies": [
23
+ "@commitlint/cli",
24
+ "@commitlint/config-conventional",
25
+ "eslint",
26
+ "eslint-config-prettier",
27
+ "eslint-import-resolver-typescript",
28
+ "eslint-plugin-import",
29
+ "prettier",
30
+ "@typescript-eslint/eslint-plugin",
31
+ "@typescript-eslint/parser"
32
+ ],
33
+ "keywords": [
34
+ "atomic",
35
+ "smash",
36
+ "coding",
37
+ "standards"
38
+ ],
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/AtomicSmash/packages",
42
+ "directory": "packages/coding-standards"
43
+ },
44
+ "homepage": "https://www.atomicsmash.co.uk/",
45
+ "license": "GPL-3.0-or-later",
46
+ "author": {
47
+ "name": "Atomic Smash",
48
+ "email": "npm@atomicsmash.co.uk",
49
+ "url": "https://www.atomicsmash.co.uk/"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ /* Expected defaults:
3
+ Prettier recommendation
4
+ printWidth: 80,
5
+
6
+ Single quotes are more often found in text strings (used for apostrophes) so using double quotes prevents lots of escaping characters.
7
+ singleQuote: false,
8
+
9
+ Keep very nested indentation near the left to prevent lots of horizontal scrolling.
10
+ tabWidth: 2,
11
+
12
+ Semicolons prevent AST errors and are more explicit where a line ends
13
+ semi: true,
14
+
15
+ Consistent line endings for MacOS and Windows
16
+ endOfLine: "lf",
17
+ */
18
+
19
+ // Tabs are better for visually impaired coders https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/
20
+ useTabs: true,
21
+
22
+ // Helps clean up git diffs by removing changes of a single comma on a line if adding a new line to the bottom
23
+ trailingComma: "all",
24
+ };
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "./base",
3
+ "exclude": [
4
+ "../node_modules/@types/jest",
5
+ "../node_modules/@testing-library/jest-dom"
6
+ ],
7
+ "include": [
8
+ "e2e/**/*",
9
+ "support/**/*",
10
+ "../node_modules/cypress",
11
+ "../node_modules/@testing-library/cypress"
12
+ ],
13
+ "compilerOptions": {
14
+ "types": ["node", "cypress", "@testing-library/cypress"],
15
+ "typeRoots": ["../types", "../node_modules/@types"]
16
+ }
17
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./base",
3
+ "exclude": ["./cypress", "./cypress.config.ts"],
4
+ "compilerOptions": {
5
+ "types": ["vitest/globals"]
6
+ }
7
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "isolatedModules": true,
4
+ "esModuleInterop": true,
5
+ "moduleResolution": "node",
6
+ "resolveJsonModule": true,
7
+ "target": "es2020",
8
+ "module": "es2020",
9
+ "strict": true,
10
+ "allowJs": true,
11
+ "checkJs": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "skipLibCheck": true,
14
+ "noEmit": true
15
+ }
16
+ }