@oncoursesystems/eslint-config 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 OnCourse Systems For Education
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,193 @@
1
+ <div align="center">
2
+ <img width="250" src="https://raw.githubusercontent.com/oncoursesystems/.github/master/assets/logo.jpg" />
3
+ <br/><br/>
4
+
5
+ # `@oncoursesystems/eslint-config`
6
+
7
+ OnCourse Systems' ESLint and Prettier config presets for JS/TS/React/ReactNative/Sencha.
8
+
9
+ <a href="https://github.com/oncoursesystems/eslint-config/blob/main/LICENSE">
10
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="OnCourse Systems ESLint config is released under the MIT license." />
11
+ </a>
12
+ <a href="https://www.npmjs.com/package/@oncoursesystems/eslint-config">
13
+ <img src="https://img.shields.io/npm/v/@oncoursesystems/eslint-config.svg" alt="NPM version" />
14
+ </a>
15
+ </div>
16
+
17
+ ## Usage
18
+
19
+ ### Install
20
+
21
+ ```bash
22
+ # NPM
23
+ npm install -D eslint @oncoursesystems/eslint-config
24
+
25
+ # PNPM
26
+ pnpm i -D esling @oncoursesystems/eslint-config
27
+ ```
28
+
29
+ Create a `esling.config.{js|ts|mjs}' file in your project root:
30
+
31
+ ```js
32
+ // eslint.config.ts
33
+ import oncourse from '@oncoursesystems/eslint-config';
34
+
35
+ export default oncourse();
36
+ ```
37
+
38
+ ### Add script for package.json
39
+
40
+ For example:
41
+
42
+ ```json
43
+ {
44
+ "scripts": {
45
+ "lint": "eslint .",
46
+ "lint:fix": "eslint . --fix"
47
+ }
48
+ }
49
+ ```
50
+
51
+ ### Config VS Code auto-fix on save
52
+
53
+ Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and create `.vscode/settings.json`
54
+
55
+ ```json
56
+ {
57
+ // Disable the default formatter, use eslint instead
58
+ "prettier.enable": false,
59
+ "editor.formatOnSave": false,
60
+
61
+ // Auto-fix on save
62
+ "editor.codeActionsOnSave": {
63
+ "source.fixAll.eslint": true,
64
+ "source.organizeImports": true
65
+ },
66
+
67
+ // Silent the stylistic rules in your IDS, but still auto-fix them
68
+ "eslint.rules.customizations": [
69
+ { "rule": "style/*", "severity": "off", "fixable": true },
70
+ { "rule": "format/*", "severity": "off", "fixable": true },
71
+ { "rule": "*-indent", "severity": "off", "fixable": true },
72
+ { "rule": "*-spacing", "severity": "off", "fixable": true },
73
+ { "rule": "*-spaces", "severity": "off", "fixable": true },
74
+ { "rule": "*-order", "severity": "off", "fixable": true },
75
+ { "rule": "*-dangle", "severity": "off", "fixable": true },
76
+ { "rule": "*-newline", "severity": "off", "fixable": true },
77
+ { "rule": "*quotes", "severity": "off", "fixable": true },
78
+ { "rule": "*semi", "severity": "off", "fixable": true }
79
+ ],
80
+
81
+ // Enable eslint for all supported languages
82
+ "eslint.validate": [
83
+ "javascript",
84
+ "javascriptreact",
85
+ "typescript",
86
+ "typescriptreact",
87
+ "html",
88
+ "markdown",
89
+ "json",
90
+ "jsonc",
91
+ "yaml",
92
+ "toml",
93
+ "xml",
94
+ "css",
95
+ "less",
96
+ "scss"
97
+ ]
98
+ }
99
+ ```
100
+
101
+ ### React Configuration
102
+
103
+ To enable React support, you need to explicitly turn it on:
104
+
105
+ ```js
106
+ // eslint.config.js
107
+ import oncourse from '@oncoursesystems/eslint-config';
108
+
109
+ export default oncourse({
110
+ react: true,
111
+ });
112
+ ```
113
+
114
+ Running npx eslint should prompt you to install the required dependencies, otherwise, you can install them manually:
115
+
116
+ ```bash
117
+ # NPM
118
+ npm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh @tanstack/eslint-plugin-query
119
+
120
+ # PNPM
121
+ pnpm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh @tanstack/eslint-plugin-query
122
+ ```
123
+
124
+ ### Sencha ExtJS Configuration
125
+
126
+ To enable Sencha ExtJS support, you need to explicitly turn it on:
127
+
128
+ ```js
129
+ // eslint.config.js
130
+ import oncourse from '@oncoursesystems/eslint-config';
131
+
132
+ export default oncourse({
133
+ react: true,
134
+ });
135
+ ```
136
+
137
+ Running npx eslint should prompt you to install the required dependencies, otherwise, you can install them manually:
138
+
139
+ ```bash
140
+ # NPM
141
+ npm i -D @sencha/eslint-plugin-extjs
142
+
143
+ # PNPM
144
+ pnpm i -D @sencha/eslint-plugin-extjs
145
+ ```
146
+
147
+ ### Customization
148
+
149
+ Configure the initial preset with the same parameters as expose [@antfu/eslint-config](https://github.com/antfu/eslint-config/blob/main/README.md#customization)
150
+
151
+ Example:
152
+
153
+ ```js
154
+ // eslint.config.ts
155
+ import oncourse from '@oncoursesystems/eslint-config';
156
+
157
+ export default oncourse(
158
+ // Configure integrations here
159
+ {
160
+ formatters: false,
161
+ },
162
+ // Any additional objects will be passed in as ESLint Flat Configs
163
+ // The files config is optional, but can be used to specify which files to lint
164
+ {
165
+ files: ['src/**/*.ts', 'src/**/*.tsx'],
166
+ rules: {
167
+ 'ts/typedef': 'off',
168
+ }
169
+ },
170
+ );
171
+ ```
172
+
173
+ ## View Enabled Rules
174
+
175
+ To view what rules are enabled in your project and apply them to files, go to your project root that contains `eslint.config.js` and run:
176
+
177
+ ```bash
178
+ npx @eslint/config-inspector
179
+ ```
180
+
181
+ ## Release & Publish
182
+
183
+ Make sure you have authenticated to your npm account using `npm login`. To publish packages, run the following command:
184
+
185
+ ```sh
186
+ pnpm run release
187
+ ```
188
+
189
+ This will auto-bump the version numbers, then upload the packages to [NPM](https://www.npmjs.com/oncoursesystems). It will also create a new GitHub release with the tagged version.
190
+
191
+ ## Credits
192
+
193
+ The project is built on top of Anthony Fu's amazing `[@antfu/eslint-config](https://github.com/antfu/eslint-config)` package.
@@ -0,0 +1,130 @@
1
+ import {
2
+ require_dist
3
+ } from "./chunk-3DH23OWQ.js";
4
+ import {
5
+ __commonJS,
6
+ init_esm_shims
7
+ } from "./chunk-UVR5GK7I.js";
8
+
9
+ // node_modules/.pnpm/eslint-plugin-expo@0.1.0_eslint@9.15.0_jiti@2.4.0__typescript@5.7.2/node_modules/eslint-plugin-expo/build/rules/noDynamicEnvVar.js
10
+ var require_noDynamicEnvVar = __commonJS({
11
+ "node_modules/.pnpm/eslint-plugin-expo@0.1.0_eslint@9.15.0_jiti@2.4.0__typescript@5.7.2/node_modules/eslint-plugin-expo/build/rules/noDynamicEnvVar.js"(exports) {
12
+ "use strict";
13
+ init_esm_shims();
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.noDynamicEnvVar = void 0;
16
+ var utils_1 = require_dist();
17
+ var createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/expo/expo/blob/main/packages/eslint-plugin-expo/docs/rules/${name}.md`);
18
+ exports.noDynamicEnvVar = createRule({
19
+ name: "no-dynamic-env-var",
20
+ meta: {
21
+ type: "problem",
22
+ docs: {
23
+ description: "Prevents process.env from being accessed dynamically"
24
+ },
25
+ schema: [],
26
+ messages: {
27
+ unexpectedDynamicAccess: "Unexpected dynamic access. Cannot dynamically access {{value}} from process.env"
28
+ }
29
+ },
30
+ defaultOptions: [],
31
+ create(context) {
32
+ return {
33
+ VariableDeclarator(node) {
34
+ const isProcessEnv = node.init?.type === "MemberExpression" && node.init.object.type === "MemberExpression" && node.init.object.object.type === "Identifier" && node.init.object.object.name === "process" && node.init.object.property.type === "Identifier" && node.init.object.property.name === "env";
35
+ if (isProcessEnv && node.init?.type === "MemberExpression" && node.init.computed) {
36
+ const identifierName = node.init.property.type === "Identifier" ? node.init.property.name : "";
37
+ const literalValue = node.init.property.type === "Literal" ? node.init.property?.value : "";
38
+ context.report({
39
+ node,
40
+ messageId: "unexpectedDynamicAccess",
41
+ data: {
42
+ value: identifierName || literalValue
43
+ }
44
+ });
45
+ }
46
+ }
47
+ };
48
+ }
49
+ });
50
+ }
51
+ });
52
+
53
+ // node_modules/.pnpm/eslint-plugin-expo@0.1.0_eslint@9.15.0_jiti@2.4.0__typescript@5.7.2/node_modules/eslint-plugin-expo/build/rules/noEnvVarDestructuring.js
54
+ var require_noEnvVarDestructuring = __commonJS({
55
+ "node_modules/.pnpm/eslint-plugin-expo@0.1.0_eslint@9.15.0_jiti@2.4.0__typescript@5.7.2/node_modules/eslint-plugin-expo/build/rules/noEnvVarDestructuring.js"(exports) {
56
+ "use strict";
57
+ init_esm_shims();
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.noEnvVarDestructuring = void 0;
60
+ var utils_1 = require_dist();
61
+ var createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://github.com/expo/expo/blob/main/packages/eslint-plugin-expo/docs/rules/${name}.md`);
62
+ exports.noEnvVarDestructuring = createRule({
63
+ name: "no-env-var-destructuring",
64
+ meta: {
65
+ type: "problem",
66
+ docs: {
67
+ description: "Disallow desctructuring of environment variables"
68
+ },
69
+ schema: [],
70
+ messages: {
71
+ unexpectedDestructuring: "Unexpected desctucturing. Cannot descructure {{value}} from process.env"
72
+ }
73
+ },
74
+ defaultOptions: [],
75
+ create(context) {
76
+ return {
77
+ VariableDeclarator(node) {
78
+ const left = node.id;
79
+ const isDestructuring = left.type === "ObjectPattern";
80
+ const isProcessEnv = node.init?.type === "MemberExpression" && node.init.object.type === "Identifier" && node.init.object.name === "process" && node.init.property.type === "Identifier" && node.init.property.name === "env";
81
+ if (isDestructuring && isProcessEnv) {
82
+ left.properties.forEach(function(property) {
83
+ context.report({
84
+ node,
85
+ messageId: "unexpectedDestructuring",
86
+ data: {
87
+ value: property.value?.type === "Identifier" ? property.value.name : "variables"
88
+ }
89
+ });
90
+ });
91
+ }
92
+ }
93
+ };
94
+ }
95
+ });
96
+ }
97
+ });
98
+
99
+ // node_modules/.pnpm/eslint-plugin-expo@0.1.0_eslint@9.15.0_jiti@2.4.0__typescript@5.7.2/node_modules/eslint-plugin-expo/build/rules/index.js
100
+ var require_rules = __commonJS({
101
+ "node_modules/.pnpm/eslint-plugin-expo@0.1.0_eslint@9.15.0_jiti@2.4.0__typescript@5.7.2/node_modules/eslint-plugin-expo/build/rules/index.js"(exports) {
102
+ "use strict";
103
+ init_esm_shims();
104
+ Object.defineProperty(exports, "__esModule", { value: true });
105
+ exports.rules = void 0;
106
+ var noDynamicEnvVar_1 = require_noDynamicEnvVar();
107
+ var noEnvVarDestructuring_1 = require_noEnvVarDestructuring();
108
+ exports.rules = {
109
+ "no-dynamic-env-var": noDynamicEnvVar_1.noDynamicEnvVar,
110
+ "no-env-var-destructuring": noEnvVarDestructuring_1.noEnvVarDestructuring
111
+ };
112
+ }
113
+ });
114
+
115
+ // node_modules/.pnpm/eslint-plugin-expo@0.1.0_eslint@9.15.0_jiti@2.4.0__typescript@5.7.2/node_modules/eslint-plugin-expo/build/index.js
116
+ var require_build = __commonJS({
117
+ "node_modules/.pnpm/eslint-plugin-expo@0.1.0_eslint@9.15.0_jiti@2.4.0__typescript@5.7.2/node_modules/eslint-plugin-expo/build/index.js"(exports, module) {
118
+ init_esm_shims();
119
+ var rules_1 = require_rules();
120
+ var plugin = {
121
+ meta: {
122
+ name: "eslint-plugin-expo",
123
+ version: "0.0.1"
124
+ },
125
+ rules: rules_1.rules
126
+ };
127
+ module.exports = plugin;
128
+ }
129
+ });
130
+ export default require_build();