Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat add eslint-plugin-prettier #54

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/eslint-plugin-best-practices/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# changelog

## 0.3.0
- Add `eslint-plugin-prettier`

## 0.2.10
- Update stylistic rules `dot-notation` and `@typescript-eslint/dot-notation` from error to off.

Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-best-practices/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iceworks/eslint-plugin-best-practices",
"version": "0.2.10",
"version": "0.3.0",
"description": "Iceworks best practices eslint plugin.",
"files": [
"docs/",
Expand Down
30 changes: 16 additions & 14 deletions packages/eslint-plugin-best-practices/src/configs/common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
plugins: ['@iceworks/best-practices'],
plugins: ['prettier', '@iceworks/best-practices'],
overrides: [
{
files: ['package.json'],
Expand All @@ -18,26 +18,28 @@ module.exports = {
},
},
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/*.{j,t}s?(x)',
'**/test/*.{j,t}s?(x)',
],
files: ['**/__tests__/*.{j,t}s?(x)', '**/tests/*.{j,t}s?(x)', '**/test/*.{j,t}s?(x)'],
env: { jest: true },
},
],
rules: {
semi: 'warn',
'dot-notation': 'off',
'max-len': ['warn', 120, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
'semi': 'warn',
'max-len': [
'warn',
120,
2,
{
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
},
],
'eol-last': 'warn',
'quote-props': 'warn',
'prettier/prettier': 'warn',
'@iceworks/best-practices/no-http-url': 'warn',
'@iceworks/best-practices/no-js-in-ts-project': 'warn',
'@iceworks/best-practices/no-lowercase-component-name': 'warn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const { deepmerge } = require('@iceworks/spec');

module.exports = deepmerge(commonConfig, {
rules: {
semi: 'off',
'max-lines': ['warn', { max: 500 }],
'no-plusplus': 'off',
'no-return-await': 'off',
'semi': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/semi': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const { deepmerge } = require('@iceworks/spec');

module.exports = deepmerge(commonConfig, {
rules: {
semi: 'off',
'max-len': ['error', { code: 150 }],
'max-lines': ['warn', { max: 500 }],
'no-plusplus': 'off',
'no-return-await': 'off',
'react/prop-types': 'off',
'semi': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/semi': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ module.exports = {
dependencyVersion.indexOf('>') > -1
) {
let newVersioning = '^1.0.0';
const dependencyPackageFile = path.join(
cwd,
'node_modules',
dependencyName,
'package.json',
);
const dependencyPackageFile = path.join(cwd, 'node_modules', dependencyName, 'package.json');
if (fs.existsSync(dependencyPackageFile)) {
const dependencyPackage = fs.readJSONSync(dependencyPackageFile);
newVersioning = `^${dependencyPackage.version}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable prettier/prettier */
const docsUrl = require('../docsUrl');

const RULE_NAME = 'no-secret-info';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,7 @@ module.exports = {
const supports = target.__compat.support;
for (let i = 0, l = Object.keys(targetBrowsers).length; i < l; i++) {
const browser = Object.keys(targetBrowsers)[i];
if (
semver.satisfies(
`${targetBrowsers[browser]}.0.0`,
`<${supports[browser].version_added}`,
)
) {
if (semver.satisfies(`${targetBrowsers[browser]}.0.0`, `<${supports[browser].version_added}`)) {
context.report({
node,
messageId: 'recommendPolyfill',
Expand Down
4 changes: 4 additions & 0 deletions packages/spec/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# changelog

## 1.5.1

- Feat add `eslint-plugin-prettier`, and set `"prettier/prettier": "warn"`.

## 1.5.0

- Feat update eslint-config-ali, babel and typescript dependencies to support [email protected].
Expand Down
12 changes: 12 additions & 0 deletions packages/spec/examples/rax/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ export default (props) => {
const source = { uri };
return <Image className="logo" source={source} />;
};

// prettier test
const a = 1; const b = 2;
const c = {
a: [
{
a: 1,
b:
2,
},
],
}
9 changes: 5 additions & 4 deletions packages/spec/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iceworks/spec",
"version": "1.5.0",
"version": "1.5.1",
"description": "Easy to use eslint/stylelint/prettier/commitlint in rax, ice and react project.",
"main": "src/index.js",
"files": [
Expand Down Expand Up @@ -36,16 +36,17 @@
"stylelint": ">=8.3.0"
},
"dependencies": {
"@iceworks/eslint-plugin-best-practices": "^0.2.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"@babel/core": "^7.16.0",
"@babel/eslint-parser": "^7.16.3",
"@babel/preset-react": "^7.16.0",
"@iceworks/eslint-plugin-best-practices": "^0.3.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"commitlint-config-ali": "^0.1.0",
"eslint-config-ali": "^13.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-plus": "^0.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-rax-compile-time-miniapp": "^1.0.0",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/spec/src/eslint/common-ts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// https://www.npmjs.com/package/eslint-config-ali
// ESlint config for common ts project
module.exports = {
extends: [
require.resolve('eslint-config-ali/typescript'),
],
extends: [require.resolve('eslint-config-ali/typescript')],
rules: {
// Change error to warn
'semi': 'off',
semi: 'off',
'@typescript-eslint/semi': 'warn',
'eol-last': 'warn',
'quote-props': 'warn',
Expand Down
6 changes: 2 additions & 4 deletions packages/spec/src/eslint/common.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// https://www.npmjs.com/package/eslint-config-ali
// ESlint config for common js project
module.exports = {
extends: [
require.resolve('eslint-config-ali'),
],
extends: [require.resolve('eslint-config-ali')],
rules: {
// Change error to warn
'semi': 'warn',
semi: 'warn',
'eol-last': 'warn',
'quote-props': 'warn',
'no-unused-vars': 'warn',
Expand Down
6 changes: 2 additions & 4 deletions packages/spec/src/eslint/vue-ts.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// https://www.npmjs.com/package/eslint-config-ali
// ESlint config for Vue TypeScript project
module.exports = {
extends: [
require.resolve('eslint-config-ali/typescript/vue'),
],
extends: [require.resolve('eslint-config-ali/typescript/vue')],
rules: {
// Change error to warn
'semi': 'off',
semi: 'off',
'@typescript-eslint/semi': 'warn',
'eol-last': 'warn',
'quote-props': 'warn',
Expand Down
6 changes: 2 additions & 4 deletions packages/spec/src/eslint/vue.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// https://www.npmjs.com/package/eslint-config-ali
// ESlint config for Vue project
module.exports = {
extends: [
require.resolve('eslint-config-ali/vue'),
],
extends: [require.resolve('eslint-config-ali/vue')],
rules: {
// Change error to warn
'semi': 'warn',
semi: 'warn',
'eol-last': 'warn',
'quote-props': 'warn',
'no-unused-vars': 'warn',
Expand Down
10 changes: 5 additions & 5 deletions packages/spec/src/getRaxEslintConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ module.exports = function (config) {
const buildConfigFilePath = path.join(process.cwd(), 'build.json');

if (fs.existsSync(buildConfigFilePath)) {

const buildConfig = JSON5.parse(fs.readFileSync(buildConfigFilePath, 'utf8'));

const isCompileTime = (target) => (
buildConfig.targets && buildConfig.targets.find((t) => t === target) &&
buildConfig[target] && buildConfig[target].buildType === 'compile'
);
const isCompileTime = (target) =>
buildConfig.targets &&
buildConfig.targets.find((t) => t === target) &&
buildConfig[target] &&
buildConfig[target].buildType === 'compile';

// At present, only miniapp and wechat-miniprogram support build for compile-time
if (isCompileTime('miniapp') || isCompileTime('wechat-miniprogram')) {
Expand Down