Skip to content

Commit

Permalink
Merge pull request #1715 from blackflux/dev
Browse files Browse the repository at this point in the history
[Gally]: master <- dev
  • Loading branch information
simlu authored Nov 10, 2023
2 parents 3fa8eb5 + b7cfeb4 commit 751688a
Show file tree
Hide file tree
Showing 8 changed files with 936 additions and 743 deletions.
3 changes: 2 additions & 1 deletion .c8rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"node_modules/*",
"coverage/*",
"lib/*",
"test/hot.js"
"test/hot.js",
"eslint.config.js"
],
"temp-directory": "./coverage/.c8_output",
"reports-dir": "./coverage",
Expand Down
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
workflows:
version: 2
node-multi-build:
jobs:
- gally-create-pr
Expand Down Expand Up @@ -30,7 +29,7 @@ workflows:
filters:
branches:
only: master
version: 2
version: 2.1
jobs:
gally-create-pr:
docker:
Expand Down
1 change: 1 addition & 0 deletions .roboconfig.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
".releaserc.json",
"LICENSE",
"README.md",
"eslint.config.js",
"gardener.js",
"package.json",
"src/index.js",
Expand Down
41 changes: 41 additions & 0 deletions CONFDOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Documents configuration tasks managed by [robo-config](https://github.com/blackf
- <a name="blackfluxrobo-config-plugin-task-idx-ref-structtemplate-index-test">:clipboard:</a> <a href="#blackfluxrobo-config-plugin-task-ref-structtemplate-index-test">`struct/template-index-test`</a>
- <a name="blackfluxrobo-config-plugin-task-idx-ref-structtemplate-index">:clipboard:</a> <a href="#blackfluxrobo-config-plugin-task-ref-structtemplate-index">`struct/template-index`</a>
- <a name="blackfluxrobo-config-plugin-task-idx-ref-structtemplate-eslintrc">:clipboard:</a> <a href="#blackfluxrobo-config-plugin-task-ref-structtemplate-eslintrc">`struct/template-eslintrc`</a>
- <a name="blackfluxrobo-config-plugin-task-idx-ref-structtemplate-eslint-config">:clipboard:</a> <a href="#blackfluxrobo-config-plugin-task-ref-structtemplate-eslint-config">`struct/template-eslint-config`</a>
- <a name="blackfluxrobo-config-plugin-task-idx-ref-semantic-releasenpm-default">:open_file_folder:</a> <a href="#blackfluxrobo-config-plugin-task-ref-semantic-releasenpm-default">`semantic-release/#npm-default`</a>
- <a name="blackfluxrobo-config-plugin-task-idx-ref-semantic-releasecommit-conventions">:clipboard:</a> <a href="#blackfluxrobo-config-plugin-task-ref-semantic-releasecommit-conventions">`semantic-release/commit-conventions`</a>
- <a name="blackfluxrobo-config-plugin-task-idx-ref-packagenpm-default">:open_file_folder:</a> <a href="#blackfluxrobo-config-plugin-task-ref-packagenpm-default">`package/#npm-default`</a>
Expand Down Expand Up @@ -71,6 +72,7 @@ Manage various configuration files for an open source npm package on github.
<code>│&nbsp;&nbsp;└─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-ideaprojectnameiml">${projectName}.iml</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-c8rcjson">.c8rc.json</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-editorconfig">.editorconfig</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-eslintconfigjs">eslint.config.js</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-eslintrcjson">.eslintrc.json</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-gallyjson">.gally.json</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-gardenerjs"><strike>gardener.js</strike></a></code><br/>
Expand Down Expand Up @@ -140,6 +142,7 @@ Manage basic project structure for npm package on github.
<td align="left" valign="top">
<ul>
<code>project</code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-eslintconfigjs">eslint.config.js</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-eslintrcjson">.eslintrc.json</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-gardenerjs"><strike>gardener.js</strike></a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-mocharcyml">.mocharc.yml</a></code><br/>
Expand Down Expand Up @@ -213,6 +216,7 @@ Manage basic project structure for npm package on github.
<td align="left" valign="top">
<ul>
<code>project</code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-eslintconfigjs">eslint.config.js</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-eslintrcjson">.eslintrc.json</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-mocharcyml">.mocharc.yml</a></code><br/>
<code>├─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-readmemd">README.md</a></code><br/>
Expand Down Expand Up @@ -414,6 +418,35 @@ _Updating <a href="#blackfluxrobo-config-plugin-target-ref-eslintrcjson">.eslint
</tbody>
</table>

###### :clipboard: <a name="blackfluxrobo-config-plugin-task-ref-structtemplate-eslint-config">struct/template-eslint-config</a> (<a href="#blackfluxrobo-config-plugin-task-idx-ref-structtemplate-eslint-config">`index`</a>)

_Updating <a href="#blackfluxrobo-config-plugin-target-ref-eslintconfigjs">eslint.config.js</a> using <a href="#blackfluxrobo-config-plugin-strat-ref-overwrite">overwrite</a>._

- Create configuration file for eslint enforcing opinionated, best practices.

<table>
<tbody>
<tr>
<th>Targets</th>
<th>Requires</th>
</tr>
<tr>
<td align="left" valign="top">
<ul>
<code>project</code><br/>
<code>└─&nbsp;<a href="#blackfluxrobo-config-plugin-target-ref-eslintconfigjs">eslint.config.js</a></code><br/>
</ul>
</td>
<td align="left" valign="top">
<ul>
<li><a href="#blackfluxrobo-config-plugin-req-ref-javascript">javascript</a></li>
<li><a href="#blackfluxrobo-config-plugin-req-ref-eslint">eslint</a></li>
</ul>
</td>
</tr>
</tbody>
</table>

#### :open_file_folder: <a name="blackfluxrobo-config-plugin-task-ref-semantic-releasenpm-default">semantic-release/#npm-default</a> (<a href="#blackfluxrobo-config-plugin-task-idx-ref-semantic-releasenpm-default">`index`</a>)

Manage semantic-release configuration for npm package on github.
Expand Down Expand Up @@ -1668,6 +1701,14 @@ Main file for the project. Exposes functionality for libraries.

*Configuration file for eslint.*

### <a name="blackfluxrobo-config-plugin-target-ref-eslintconfigjs">eslint.config.js</a> ([`link`](https://eslint.org/docs/latest/use/configure/configuration-files-new))

:small_red_triangle: <a href="#blackfluxrobo-config-plugin-req-ref-eslint">eslint</a>

:small_blue_diamond: `nostruct`

*Configuration file for eslint.*

### <a name="blackfluxrobo-config-plugin-target-ref-releasercjson">.releaserc.json</a> ([`link`](https://semantic-release.gitbook.io/semantic-release/usage/configuration#configuration-file))

:small_red_triangle: <a href="#blackfluxrobo-config-plugin-req-ref-semantic-release">semantic-release</a>
Expand Down
65 changes: 65 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* eslint-disable import/no-extraneous-dependencies */
import fs from 'smart-fs';
import { FlatCompat } from '@eslint/eslintrc';
import parser from '@babel/eslint-parser';
import blackfluxRulesPlugin from '@blackflux/eslint-plugin-rules';

const compat = new FlatCompat({
baseDirectory: fs.dirname(import.meta.url),
resolvePluginsRelativeTo: fs.dirname(import.meta.url)
});

export default [
...compat.extends(
'airbnb-base',
'plugin:mocha/recommended',
'plugin:markdown/recommended'
),
...compat.env({ es6: true, node: true, mocha: true }),
...compat.plugins('json', 'mocha'),
{
plugins: {
'@blackflux/rules': blackfluxRulesPlugin
},
languageOptions: {
parser,
parserOptions: { requireConfigFile: false }
},
rules: {
'@blackflux/rules/c8-prevent-ignore': 1,
'@blackflux/rules/kebab-case-enforce': 1,
'max-len': ['error', { code: 120 }],
'mocha/no-exclusive-tests': 'error',
'prefer-destructuring': ['error', { object: false, array: false }],
'comma-dangle': ['error', 'never'],
indent: ['error', 2, { SwitchCase: 1 }],
quotes: [2, 'single', { avoidEscape: true }],
'linebreak-style': [2, 'unix'],
semi: [2, 'always'],
'no-unused-vars': [
1,
{ vars: 'all', args: 'none', ignoreRestSiblings: true }
],
'no-var': [1],
'no-fallthrough': [1],
'spaced-comment': [
'error',
'always',
{
line: { exceptions: ['-', '+'], markers: ['=', '!'] },
block: {
exceptions: ['-', '+'],
markers: ['=', '!', ':', '::'],
balanced: true
}
}
],
'@blackflux/rules/prevent-typeof-object': 1,
'mocha/no-mocha-arrows': 0,
'mocha/no-hooks-for-single-case': 0,
'import/no-useless-path-segments': [2, { commonjs: true }],
'import/extensions': [2, 'always'],
'import/prefer-default-export': 0
}
}
];
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
"ci"
],
"devDependencies": {
"@babel/core": "7.22.9",
"@babel/eslint-parser": "7.22.9",
"@babel/register": "7.22.5",
"@blackflux/eslint-plugin-rules": "3.0.0",
"@blackflux/robo-config-plugin": "9.1.9",
"@babel/core": "7.23.3",
"@babel/eslint-parser": "7.23.3",
"@babel/register": "7.22.15",
"@blackflux/eslint-plugin-rules": "3.0.1",
"@blackflux/robo-config-plugin": "9.2.4",
"c8": "8.0.1",
"chai": "4.3.7",
"eslint": "8.46.0",
"chai": "4.3.10",
"eslint": "8.53.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.28.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-json": "3.1.0",
"eslint-plugin-markdown": "3.0.1",
"eslint-plugin-mocha": "10.1.0",
"js-gardener": "5.0.1",
"node-tdd": "4.0.0"
"eslint-plugin-mocha": "10.2.0",
"js-gardener": "5.0.3",
"node-tdd": "4.0.1"
},
"engines": {
"node": ">= 16"
Expand Down Expand Up @@ -72,15 +72,15 @@
"dependencies": {
"chalk": "5.3.0",
"fancy-log": "2.0.0",
"glob": "10.3.3",
"joi-strict": "3.0.0",
"glob": "10.3.10",
"joi-strict": "3.0.1",
"js-yaml": "4.1.0",
"lodash.difference": "4.5.0",
"mocha": "10.2.0",
"npm-check": "6.0.1",
"plugin-name-to-package-name": "0.1.1",
"robo-config": "6.0.0",
"smart-fs": "4.0.0"
"robo-config": "6.0.1",
"smart-fs": "4.0.1"
},
"resolutions": {
"strip-ansi": "^6.0.0",
Expand Down
34 changes: 13 additions & 21 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
import path from 'path';
import fs from 'smart-fs';
import { sync as globSync } from 'glob';
import { sync } from 'glob';

const globSync = (wildcard, folder, ignore) => sync(
wildcard,
{ cwd: folder, ignore, dot: true }
)
.map((files) => files.split(path.sep).join(path.posix.sep));

export const getEsLintFiles = (folder, ignore) => globSync(
'**/*.{js,json,md}',
{
cwd: folder,
ignore,
dot: true
}
folder,
ignore
);

export const getTestFiles = (folder) => globSync(
'test/**/*.spec.js',
{
cwd: folder,
ignore: [
'**/node_modules/**',
'**/coverage/**'
],
dot: true
}
folder,
['**/node_modules/**', '**/coverage/**']
);

export const getYamlFiles = (folder) => globSync(
'**/*.{yml,yaml}',
{
cwd: folder,
ignore: [
'**/node_modules/**'
],
dot: true
}
folder,
['**/node_modules/**']
);

export const loadConfig = (cwd, name) => {
Expand Down
Loading

0 comments on commit 751688a

Please sign in to comment.