Skip to content

Commit

Permalink
feat: updated rules for stylelint
Browse files Browse the repository at this point in the history
feat: updated postinstall script in textlint
  • Loading branch information
prisis committed Feb 8, 2021
1 parent 8b3a7f3 commit fdd469c
Show file tree
Hide file tree
Showing 36 changed files with 2,845 additions and 1,883 deletions.
43 changes: 0 additions & 43 deletions .github/workflows/markdown-lint.yml

This file was deleted.

1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ package-lock.json
shrinkwrap.json

# Build outputs
dist
lib

# Prettier reformats code blocks inside Markdown, which affects rendered output
Expand Down
2,979 changes: 1,877 additions & 1,102 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/config/rush/pnpmfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ function readPackage(packageJson, context) {
// packageJson.dependencies['log4js'] = '0.6.38';
// }

return packageJson;
return packageJson;
}
2 changes: 1 addition & 1 deletion packages/babel-preset/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = {
[
"@anolilab/babel-preset",
{
targets: Object.assign({}, require(browserslist - config - anolilab), {
targets: Object.assign({}, require("browserslist-config-anolilab"), {
chrome: 42,
explorer: 8,
}),
Expand Down
52 changes: 52 additions & 0 deletions packages/babel-preset/lib/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node

if (process.env.CI) {
process.exit();
}

const fs = require("fs");
const path = require("path");
const { promisify } = require("util");

const writeFileAsync = promisify(fs.writeFile);

// get the path to the host project.
const projectPath = path.resolve(process.cwd(), "..", "..", "..");

console.log("Configuring @anolilab/babel-preset", projectPath, "\n");

/**
* Writes .babelrc.js if it doesn't exist. Warns if it exists.
*/
const writeBabelRc = () => {
const eslintPath = path.join(projectPath, ".babelrc.js");
const content = `module.exports = {
presets: ["@anolilab/babel-preset"]
};
`;

if (fs.existsSync(eslintPath)) {
console.warn(`⚠️ .babelrc.js already exists;
Make sure that it includes the following for @anolilab/babel-preset'
to work as it should: { presets: ["@anolilab/babel-preset"] }.`);

return Promise.resolve();
}

return writeFileAsync(eslintPath, content, "utf-8");
};

(async () => {
try {
await writeBabelRc();

console.log("😎 Everything went well, have fun!");

process.exit();
} catch (err) {
console.log("😬 something went wrong:");
console.error(err.message);

process.exit(1);
}
})();
3 changes: 3 additions & 0 deletions packages/babel-preset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"CHANGELOG.md",
"LICENSE.md"
],
"scripts": {
"postinstall": "node lib/postinstall.js"
},
"dependencies": {
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/plugin-proposal-class-properties": "^7.12.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/browserslist-config-anolilab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $ npm install browserslist-config-anolilab --save-dev
Alternatively, add this to `.browserslistrc` file:

```
extends browserslist-config-growcss
extends browserslist-config-anolilab
```

or when using [babel-preset-env](https://github.com/babel/babel/tree/master/experimental/babel-preset-env)
Expand All @@ -57,7 +57,7 @@ or when using [babel-preset-env](https://github.com/babel/babel/tree/master/expe
'env',
{
targets: {
browsers: require('browserslist-config-growcss'),
browsers: require('browserslist-config-anolilab'),
},
},
],
Expand Down
19 changes: 9 additions & 10 deletions packages/browserslist-config-anolilab/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module.exports = [
'> 1%',
'ie >= 11',
'last 1 Android versions',
'last 1 ChromeAndroid versions',
'last 2 Chrome versions',
'last 2 Firefox versions',
'last 2 Safari versions',
'last 2 iOS versions',
'last 2 Edge versions',
'last 2 Opera versions',
"> 1%",
"last 1 Android versions",
"last 1 ChromeAndroid versions",
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"last 2 iOS versions",
"last 2 Edge versions",
"last 2 Opera versions",
];
2 changes: 1 addition & 1 deletion packages/browserslist-config-anolilab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browserslist-config-anolilab",
"version": "1.0.0",
"version": "0.0.0",
"description": "Shared Anolilab browserlist config.",
"keywords": [
"browserslist",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const pluginRules = [
"simple-import-sort",
"switch-case",
"unicorn",
"you-dont-need-lodash-underscore",
"you-dont-need-momentjs",

// Security Rules
"no-secrets",
Expand Down
32 changes: 24 additions & 8 deletions packages/eslint-config/lib/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const projectPath = path.resolve(process.cwd(), "..", "..", "..");
console.log("Configuring @anolilab/eslint-config", projectPath, "\n");

/**
* Writes .eslintrc.js.js if it doesn't exist. Warns if it exists.
* Writes .eslintrc.js if it doesn't exist. Warns if it exists.
*/
const writeEslintRc = () => {
const eslintPath = path.join(projectPath, ".eslintrc.js.js");
const eslintPath = path.join(projectPath, ".eslintrc.js");
const content = `module.exports = {
extends: ["@anolilab/eslint-config"],
env: {
Expand Down Expand Up @@ -55,7 +55,7 @@ to work as it should: { extends: ["@anolilab/eslint-config"] }.`);
};

/**
* Writes .prettierrc if it doesn't exist. Warns if it exists.
* Writes .prettierrc.js if it doesn't exist. Warns if it exists.
*/
const writePrettierRc = () => {
const prettierPath = path.join(projectPath, ".prettierrc.js");
Expand Down Expand Up @@ -101,8 +101,8 @@ const writePrettierRc = () => {
embeddedLanguageFormatting: "auto",
};

if (fs.existsSync(prettierPath)) {
console.warn(`⚠️ .prettierrc already exists;
if (fs.existsSync(prettierPath) || fs.existsSync(prettierPath.replace('.js', ''))) {
console.warn(`⚠️ .prettierrc.js already exists;
Make sure that it includes the following for @anolilab/eslint-config to work as it should:
${JSON.stringify(content, null, 4)}\n`);

Expand All @@ -116,12 +116,28 @@ ${JSON.stringify(content, null, 4)}\n`);
);
};

/**
* Writes .prettierignore if it doesn't exist. Warns if it exists.
*/
const writePrettierIgnore = () => {
const prettierPath = path.join(projectPath, ".prettierignore");

if (fs.existsSync(prettierPath)) {
console.warn(`⚠️ .prettierignore already exists`);

return Promise.resolve();
}

return writeFileAsync(prettierPath, "", "utf-8");
};

(async () => {
try {
const promises = [writeEslintRc()]
const promises = [writeEslintRc()];

if (hasAnyDep('prettier')) {
promises.push(writePrettierRc())
if (hasAnyDep("prettier")) {
promises.push(writePrettierRc());
promises.push(writePrettierIgnore())
}

await Promise.all(promises);
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-sort-keys-fix": "^1.1.1",
"eslint-plugin-unicorn": "^27.0.0",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.11.0",
"eslint-plugin-you-dont-need-momentjs": "^1.6.0",
"lodash.has": "^4.5.2",
"object.assign": "^4.1.2",
"putout": "^14.0.3",
Expand Down
Loading

0 comments on commit fdd469c

Please sign in to comment.