@jgarber/eslint-config 1.0.0 → 1.1.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/.editorconfig ADDED
@@ -0,0 +1,10 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ indent_size = 2
9
+ indent_style = space
10
+ trim_trailing_whitespace = true
@@ -0,0 +1,15 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ assignees:
9
+ - "jgarber623"
10
+ - package-ecosystem: "npm"
11
+ directory: "/"
12
+ schedule:
13
+ interval: "monthly"
14
+ assignees:
15
+ - "jgarber623"
@@ -0,0 +1,27 @@
1
+ name: CI
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ lint:
7
+ name: Lint files
8
+ runs-on: ubuntu-20.04
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - uses: actions/setup-node@v3
12
+ with:
13
+ node-version-file: ".nvmrc"
14
+ cache: npm
15
+ - run: npm ci
16
+ - run: npm run lint
17
+ test:
18
+ name: Test files
19
+ runs-on: ubuntu-20.04
20
+ steps:
21
+ - uses: actions/checkout@v3
22
+ - uses: actions/setup-node@v3
23
+ with:
24
+ node-version-file: ".nvmrc"
25
+ cache: npm
26
+ - run: npm ci
27
+ - run: npm test
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ lts/*
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  Shareable [ESLint](https://eslint.org) configuration.
4
4
 
5
5
  > **Note**
6
+ >
6
7
  > As of v1.0.0, this shareable configuration uses ESLint's new "flat" configuration file format and, thus, may not be suitable for every project. See [the official documentation](https://eslint.org/docs/latest/use/configure/configuration-files-new) for details.
7
8
 
8
9
  ## Installation
package/eslint.config.js CHANGED
@@ -1,32 +1,15 @@
1
- /*
2
- * Import Standard's ESLint configurtation for use with ESLint's new "flat"
3
- * configuration file format.
4
- *
5
- * @see {@link https://github.com/standard/eslint-config-standard/blob/master/.eslintrc.json}
6
- * @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new}
7
- */
8
- const standard = require('eslint-config-standard');
1
+ const globals = require('globals');
9
2
 
10
- module.exports = [
11
- {
12
- plugins: Object.fromEntries(standard.plugins.map(plugin => [plugin, require(`eslint-plugin-${plugin}`)])),
13
- rules: {
14
- ...standard.rules,
3
+ const config = require('./index');
15
4
 
16
- // Enforces consistent use of semicolons.
17
- semi: ['error', 'always']
18
- }
19
- },
5
+ module.exports = [
6
+ ...config,
20
7
  {
21
- /*
22
- * By default, ESLint's "flat" config considers `*.js` files as ECMAScript
23
- * modules (ESM). Instead, consider `*.js` files to be CommonJS modules.
24
- *
25
- * @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects}
26
- */
27
- files: ['**/*.js'],
8
+ files: ['spec/**/*[sS]pec.?(m)js'],
28
9
  languageOptions: {
29
- sourceType: 'commonjs'
10
+ globals: {
11
+ ...globals.jasmine
12
+ }
30
13
  }
31
14
  }
32
15
  ];
package/index.js CHANGED
@@ -1 +1,59 @@
1
- module.exports = require('./eslint.config.js');
1
+ /*
2
+ * Import global identifiers from different JavaScript environments.
3
+ *
4
+ * @see {@link https://www.npmjs.com/package/globals}
5
+ * @see {@link https://github.com/sindresorhus/globals/blob/HEAD/globals.json}
6
+ */
7
+ const globals = require('globals');
8
+
9
+ /*
10
+ * Import Standard's ESLint configurtation for use with ESLint's new "flat"
11
+ * configuration file format.
12
+ *
13
+ * @see {@link https://github.com/standard/eslint-config-standard/blob/master/.eslintrc.json}
14
+ * @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new}
15
+ */
16
+ const standard = require('eslint-config-standard');
17
+
18
+ module.exports = [
19
+ {
20
+ plugins: Object.fromEntries(standard.plugins.map(plugin => [plugin, require(`eslint-plugin-${plugin}`)])),
21
+ rules: {
22
+ ...standard.rules,
23
+
24
+ /*
25
+ * Enforces consistent use of semicolons.
26
+ *
27
+ * @see {@link https://eslint.org/docs/latest/rules/semi}
28
+ */
29
+ semi: ['error', 'always'],
30
+
31
+ /*
32
+ * Enforces consistent spacing before function parentheses and will warn
33
+ * whenever whitespace doesn't match the preferences specified.
34
+ *
35
+ * @see {@link https://eslint.org/docs/latest/rules/space-before-function-paren}
36
+ */
37
+ 'space-before-function-paren': ['error', {
38
+ anonymous: 'never',
39
+ asyncArrow: 'always',
40
+ named: 'never'
41
+ }]
42
+ }
43
+ },
44
+ {
45
+ /*
46
+ * By default, ESLint's "flat" config considers `*.js` files as ECMAScript
47
+ * modules (ESM). Instead, consider `*.js` files to be CommonJS modules.
48
+ *
49
+ * @see {@link https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects}
50
+ */
51
+ files: ['**/*.js'],
52
+ languageOptions: {
53
+ globals: {
54
+ ...globals.commonjs
55
+ },
56
+ sourceType: 'commonjs'
57
+ }
58
+ }
59
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jgarber/eslint-config",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Shareable ESLint configuration.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -12,24 +12,25 @@
12
12
  "bugs": "https://github.com/jgarber623/eslint-config/issues",
13
13
  "license": "MIT",
14
14
  "author": "Jason Garber <jason@sixtwothree.org> (https://sixtwothree.org)",
15
- "files": [
16
- "eslint.config.js"
17
- ],
18
15
  "main": "index.js",
19
16
  "repository": "github:jgarber623/eslint-config",
20
17
  "scripts": {
21
- "test": "eslint ."
18
+ "lint": "eslint .",
19
+ "test": "jasmine"
22
20
  },
23
21
  "engines": {
24
22
  "node": ">=16.0.0"
25
23
  },
26
24
  "devDependencies": {
27
25
  "eslint": "^8.43.0",
28
- "eslint-config-standard": "^17.1.0"
26
+ "eslint-config-standard": "^17.1.0",
27
+ "globals": "^13.20.0",
28
+ "jasmine": "^5.0.2"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "eslint": ">=8.43.0",
32
- "eslint-config-standard": ">=17.1.0"
32
+ "eslint-config-standard": ">=17.1.0",
33
+ "globals": ">=13.20.0"
33
34
  },
34
35
  "publishConfig": {
35
36
  "access": "public"
@@ -0,0 +1,24 @@
1
+ const { FlatESLint } = require('eslint/use-at-your-own-risk');
2
+
3
+ const config = require('../index');
4
+
5
+ it('exports an Array', () => {
6
+ expect(Array.isArray(config)).toBe(true);
7
+ });
8
+
9
+ it('loads the config and validates correct syntax', async () => {
10
+ const eslint = new FlatESLint({ baseConfig: config });
11
+ const [results] = await eslint.lintText(';\n');
12
+
13
+ expect(results.errorCount).toEqual(0);
14
+ });
15
+
16
+ it('loads the config and invalidates incorrect syntax', async () => {
17
+ const eslint = new FlatESLint({ baseConfig: config });
18
+ const [results] = await eslint.lintText('(() => {}) ()\n');
19
+
20
+ const ruleIds = results.messages.map(({ ruleId }) => ruleId);
21
+
22
+ expect(results.errorCount).toEqual(2);
23
+ expect(ruleIds).toEqual(jasmine.arrayContaining(['func-call-spacing', 'semi']));
24
+ });
@@ -0,0 +1,14 @@
1
+ {
2
+ "spec_dir": "spec",
3
+ "spec_files": [
4
+ "**/*[sS]pec.?(m)js"
5
+ ],
6
+ "helpers": [
7
+ "helpers/**/*.?(m)js"
8
+ ],
9
+ "env": {
10
+ "failSpecWithNoExpectations": true,
11
+ "random": true,
12
+ "stopSpecOnExpectationFailure": false
13
+ }
14
+ }